validating data in PHP
<p>I have a form like below and I want to get some input from the user. My goal is to validate the data before submitting into database. My question is how do I do this ?</p>

<pre><code>&lt;form action="../actions/insertcomment.php" method="post"&gt;
    &lt;p class ="ctitle"&gt;Leave a Comment:&lt;/p&gt;
    &lt;p&gt;&lt;label for="postid"&gt;&lt;b&gt;PostID:&lt;/b&gt;&lt;/label&gt;
       &lt;input type="text" id="postid" name="postid" maxlength="5" /&gt; &lt;br/&gt;

        &lt;label for="name"&gt;&lt;b&gt;Name:&lt;/b&gt;&lt;/label&gt;
        &lt;input type="text" id="name" name="name" maxlength="25" /&gt; &lt;br/&gt;

        &lt;label for="email"&gt;&lt;b&gt;Email:&lt;/b&gt;&lt;/label&gt;
        &lt;input type="text" id="email" name="email" maxlength="50" /&gt; &lt;br/&gt;

        &lt;label for="website"&gt;&lt;b&gt;Website:&lt;/b&gt;&lt;/label&gt;
        &lt;input type="text" id="website" name="website" maxlength="25" /&gt; &lt;br/&gt;

        &lt;label for="content"&gt;&lt;b&gt;Comment:&lt;/b&gt;&lt;/label&gt;
        &lt;textarea id="content" name="content" cols="10" rows="4" maxlength="100"&gt;&lt;/textarea&gt; &lt;br/&gt;

        &lt;input type="submit" value="Submit Comment" name="submit_comment" /&gt; &lt;br/&gt;
    &lt;/p&gt;
&lt;/form&gt;
</code></pre>

<p>and my insercomment.php is as follows:</p>

<pre><code>&lt;html&gt;
&lt;link rel = "stylesheet" type = "text/css"
          href = "../common/style.css" /&gt;
&lt;?php
include("../common/dbconnect.php");
$con=new dbconnect();
$con-&gt;connect();
error_reporting(E_ALL);

 //$postid= $_GET['id'];

if($_POST) {

    $postid= $_POST['postid'];
    $users_name = $_POST['name'];
    $users_email = $_POST['email'];
    $users_website = $_POST['website'];
    $users_comment = $_POST['content'];

    $postid = htmlspecialchars($postid);
    $users_name = htmlspecialchars($users_name);
    $users_email = htmlspecialchars($users_email);
    $users_website = htmlspecialchars($users_website);
    $users_comment = htmlspecialchars($users_comment);



$sSql = "INSERT INTO comments
 ( post_id,name, email, website,content)
 VALUES ( $postid, '$users_name',
        '$users_email', '$users_website', '$users_comment' )";

    //echo $sSql;
    mysql_query($sSql);
    //$update=mysql_affected_rows();
    //echo "&lt;h2&gt;$update Record Inserted&lt;/h2&gt;&lt;br /&gt;";
    echo '&lt;h2&gt; Your Comment is submitted&lt;/h2&gt;&lt;br /&gt;';
}

?&gt;
</code></pre>

<p>Here I am not using " method="post"> Any code or example for this kind is appreciated.</p>
