PHP Form Validation Code
<p>I have checked all this code carefully but still it doesnt work not sure why. The error is when i fill all options it still shows "Please fill all the fields"</p>

<pre><code>&lt;?php
if (!empty($_POST['username']) &amp;&amp; !empty($_POST['password']) &amp;&amp; !empty($_POST['password_again']) &amp;&amp; !empty($_POST['gender']) &amp;&amp; !empty($_POST['info']) ){
     $username = $_POST['username'];

}   
else{
    echo "You need to fill all fields";
}
?&gt;


&lt;!DOCTYPE HTML&gt;
 &lt;html&gt;
&lt;body&gt;
&lt;form method= "post"&gt;
&lt;h2&gt;Register&lt;/h2&gt;
username:&lt;input type ="text" name ="usename"/&gt;&lt;br/&gt;
password:&lt;input type ="password" name ="password"/&gt;&lt;br/&gt;
password again:&lt;input type ="password" name ="password_again"/&gt;&lt;br/&gt;
Gender: male&lt;input type ="radio" value="male" name ="gender"/&gt; female&lt;input       type ="radio" value="female" name ="gender"/&gt;&lt;br/&gt;
Tell us about yourself:&lt;br/&gt;
&lt;textarea name="info"&gt;
&lt;/textarea&gt;
&lt;br/&gt;
&lt;input type ="submit" value = "submit"/&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>