title: Setting minimum length of characters for post
body: <p>I got code for posting title and body of blog along with few other things. Now I want to set minimum length of characters for title and body using strlen, my code is</p>
  
  <pre><code> if(isset($_POST['submit'])) {
     $title=$_POST['title'];
     $body=$_POST['body'];
     $category=$_POST['category'];
     $title = mysql_real_escape_string($title);
     $body = mysql_real_escape_string($body);
     $posted_by = $user;
     $bio = $bio;
     $id=$_SESSION['id'];
     $date = date ('Y-m-d');
     $body = htmlentities($body);
     if ($title &amp;&amp; $body &amp;&amp; $category) {
        $query = mysql_query("INSERT INTO blogs (id, title, body, posted_by, bio, category_id, posted) VALUES ('$id', '$title', '$body', '$posted_by','$bio', '$category', '$date')");
        if($query) {
          echo "posted";
        }
        else {
          echo "error";
        }
     }else {
      echo "data missing";
     }
  }
  </code></pre>
  
  <p>This code works fine just want to insert minimum characters requirement for title and body. I have tried few if else statements with strlen but I am not programming expert so I get syntax errors.</p>