Trouble with validation after registration
<p>I'm doing a registration page. It requires the name, password, email, gender, nationality, date of birth and other things. </p>

<p>I did the registration and it was good. But I need to add the validation and this is what I could do so far:</p>

<pre><code>&lt;?php include("config.php"); ?&gt;
    &lt;!DOCTYPE html&gt;
    &lt;html lang="en"&gt;

    &lt;!-- CSS --&gt;
    &lt;link rel="stylesheet" href="css/styles.css" type="text/css"/&gt;
    &lt;link type="text/css" href="css/jquery-ui-1.7.2.custom.css" rel="stylesheet" /&gt; 

    &lt;!-- JavaScript --&gt;
    &lt;script type="text/javascript" src="js/jquery-1.3.2.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"&gt;&lt;/script&gt;
    &lt;script src="js/validation.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        $(function(){
                    $('#datepicker').datepicker({
                        dateFormat:'dd/mm/yy',
                        changeMonth: true,
                        changeYear: true,
                        yearRange: '-90:+0',
                        maxDate: '+0'
                    });
        });
    &lt;/script&gt;
    &lt;/head&gt;

    &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link rel="stylesheet" href="css/reset.css" type="text/css" media="all"&gt;
    &lt;link rel="stylesheet" href="css/layout.css" type="text/css" media="all"&gt;
    &lt;link rel="stylesheet" href="css/style.css" type="text/css" media="all"&gt;
    &lt;script type="text/javascript" src="js/jquery-1.4.2.js" &gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/cufon-yui.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/cufon-replace.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/Myriad_Pro_italic_600.font.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/Myriad_Pro_italic_400.font.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/Myriad_Pro_400.font.js"&gt;&lt;/script&gt;
    &lt;!--[if lt IE 9]&gt;
        &lt;script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="js/html5.js"&gt;&lt;/script&gt;
    &lt;![endif]--&gt;
    &lt;?php $error_messages = array(
        'T1' =&gt; 'Please enter a Name to proceed.',
        'T2' =&gt; 'Please enter a valid Email Address to continue.',
        'T3' =&gt; 'Please enter your Message to continue.'
    ); 
    ?&gt;
    &lt;/head&gt;
    &lt;body id="page2"&gt;
    &lt;div class="body1"&gt;
        &lt;div class="main"&gt;
    &lt;!-- header --&gt;
            &lt;header&gt;
                &lt;div class="wrapper"&gt;
                    &lt;h1&gt;&lt;a href="index.html" id="logo"&gt;Air Lines&lt;/a&gt;&lt;span id="slogan"&gt;International Travel&lt;/span&gt;&lt;/h1&gt;
                    &lt;div class="right"&gt;
                        &lt;nav&gt;
                            &lt;ul id="top_nav"&gt;
                                &lt;li&gt;&lt;a href="index.html"&gt;&lt;img src="images/img1.gif" alt=""&gt;&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href="index-4.html"&gt;&lt;img src="images/img2.gif" alt=""&gt;&lt;/a&gt;&lt;/li&gt;
                                &lt;li class="bg_none"&gt;&lt;a href="#"&gt;&lt;img src="images/img3.gif" alt=""&gt;&lt;/a&gt;&lt;/li&gt;





                            &lt;/ul&gt;
                        &lt;/nav&gt;
                        &lt;nav&gt;
                            &lt;ul id="menu"&gt;
    &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
                                &lt;li  id="menu_active" &gt;&lt;a href="LSU.php"&gt;Login/sign up&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href="V&amp;M.php"&gt;Vision and mission&lt;/a&gt;&lt;/li&gt;

                                &lt;li&gt;&lt;a href="contact.php"&gt;Contacts&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                        &lt;/nav&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/header&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="main"&gt;
        &lt;div id="banner"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- header --&gt;
    &lt;div class="main"&gt;
    &lt;!-- content --&gt;
        &lt;section id="content"&gt;
            &lt;article class="col1"&gt;
                &lt;div class="pad_1"&gt;
                    &lt;h2&gt;Login&lt;/h2&gt;
                  &lt;form id="form_1" action="login.php" method="post"&gt;

                        &lt;div class="wrapper"&gt;
                            User Name:
                            &lt;div class="bg"&gt;&lt;input type="text" name="LogIn_Name" class="input input1" value="Enter your name" onblur="if(this.value=='') this.value='Enter your name'" onfocus="if(this.value =='Enter your name' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;
                    &lt;div class="wrapper"&gt;
                            Password:
                            &lt;div class="bg"&gt;&lt;input type="password" name="LogIn_Pass" class="input input1" value="Enter your password" onblur="if(this.value=='') this.value='Enter your password'" onfocus="if(this.value =='Enter your password' ) this.value=''"&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="wrapper"&gt;

                        &lt;h2 id="coq"&gt; &lt;a href="Forget.php"&gt;Forget Password&lt;/a&gt;&lt;/h2&gt;

                          &lt;input type="submit" class="button2" value="GO"&gt;
                    &lt;/div&gt;
                    &lt;/form&gt;



                    &lt;h2&gt;&amp;nbsp;&lt;/h2&gt;
                &lt;/div&gt;
            &lt;/article&gt;
            &lt;article class="col2 pad_left1"&gt;
                &lt;h2&gt;Registration&lt;/h2&gt;
                &lt;div class="wrapper"&gt;
                    &lt;figure class="left marg_right1"&gt;&lt;/figure&gt;
                    &lt;p&gt; 

                                    &lt;form id="form_1" action="" method="post"&gt;
    &lt;div class="wrapperr"  &gt;
    &lt;?php 

    $username =  $_POST["T1"];
    $password =  $_POST["T2"];
    $repassword =  $_POST["T3"];
    $email =  $_POST["T4"];
    $gender =  $_POST["T5"];
    $Cou =  $_POST["T6"];
    $DO=  $_POST["T7"];
    $passport=  $_POST["T8"];
    $phone=  $_POST["T9"];

    {
    if((strlen($username)&lt;3)){
    echo "The username is too short"."&lt;/br&gt;";


    if((strlen($gender)&lt;3)){
    echo "Gender"."&lt;/br&gt;";
    }


    if((strlen($Cou)&lt;2)){
    echo "The CO too short"."&lt;/br&gt;";
    }


    if((strlen($phone)&lt;5)){
    echo "The phone is too short"."&lt;/br&gt;";
    }

    if((strlen($password)&lt;5)){
    echo "The password is too short"."&lt;/br&gt;";
    }
    }
    else{
    if($password == $repassword){
    $chec = mysql_query("SELECT * FROM register WHERE name='$username'"); 
    if(strlen($chec['name'])&gt;0){
    echo "The username '$username' already exists";
    }
    else{
    $check_variable=stripos($email,"@");
    if($check_variable){

    $password=md5($password);
    mysql_query("INSERT INTO register (name,password,email,gender,country,DOB,phone,passport) VALUES ('$username','$password','$email','$gender','$Cou','$DO','$phone','$passport')");
    echo "Registration Successful .. Click &lt;a href='index.php'&gt; here &lt;/a&gt; to home";
    }
    else{
    echo "email is invalid";
    }
    }
    }
    else{
    echo "The password in both field doesn't match.";
    }
    }
    }






    ?&gt;
        &lt;/div&gt;              &lt;div class="wrapper"&gt;
                            Name:
                            &lt;div class="bg"&gt;&lt;input type="text" name="T1" class="input input1"  value="Enter your name" onblur="if(this.value=='') this.value='Enter your name'" onfocus="if(this.value =='Enter your name' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;

                                            &lt;div class="wrapper"&gt;
                            Password:
                            &lt;div class="bg"&gt;&lt;input type="password" name="T2"  class="input input1" value="Enter the password" onblur="if(this.value=='') this.value='Enter the password'" onfocus="if(this.value =='Enter the password' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;


                                            &lt;div class="wrapper"&gt;
                            Confirm password:
                            &lt;div class="bg"&gt;&lt;input type="password" name="T3" class="input input1" value="Confirm the password" onblur="if(this.value=='') this.value='Confirm the password'" onfocus="if(this.value =='Confirm the password' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;

                                            &lt;div class="wrapper"&gt;
                            e-mail:
                            &lt;div class="bg"&gt;&lt;input type="text" name = "T4" class="input input1" value="Enter your e-mail" onblur="if(this.value=='') this.value='Enter your e-mail'" onfocus="if(this.value =='Enter your e-mail' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;


                        &lt;div class="wrapper"&gt;
                            Gender:
                            &lt;div class="bg"&gt;
                              &lt;td&gt;
                              &lt;input type="radio" name="T5" value="Male"&gt;
                              Male
                              &lt;/td&gt;&lt;td&gt;
                               &lt;input type="radio" name="T5" value="Female"&gt;
                              Female&lt;/td&gt;


                          &lt;/div&gt;
                        &lt;/div&gt;


                                    &lt;div class="wrapper"&gt;
                            NATIONALITY:
                              &lt;div class="bg"&gt;&lt;input type="text" name="T6" class="input input1" value="Enter your country" onblur="if(this.value=='') this.value='Enter your country'" onfocus="if(this.value =='Enter your country' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;


                        &lt;div class="wrapper"&gt;

                                                        &lt;div class="wrapper"&gt;
                            Passport number:
                              &lt;div class="bg"&gt;&lt;input type="text" name="T8" class="input input1" value="Enter your passport number" onblur="if(this.value=='') this.value='Enter your passport number'" onfocus="if(this.value =='Enter your passport number' ) this.value=''"&gt;&lt;/div&gt;
                        &lt;/div&gt;


                        &lt;div class="wrapper"&gt;


                            Date of birth:
                      &lt;div class="wrapper"&gt;
                                &lt;div class="bg left"&gt;&lt;input type="text" name="T7" class="input input2" value="mm/dd/yyyy " onblur="if(this.value=='') this.value='mm/dd/yyyy '" onfocus="if(this.value =='mm/dd/yyyy ' ) this.value=''" id="datepicker"  &gt;
                                  &lt;br/&gt;&lt;span id="bdayInfo"&gt;&lt;/span&gt;

                        &lt;/div&gt;
                                &lt;div class="bg right"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        Phone number:
                                                &lt;div class="wrapper"&gt;
                                &lt;div class="bg left"&gt;&lt;input type="text" name="T9" class="input input2" value="" onblur="if(this.value=='') this.value=''" onfocus="if(this.value =='' ) this.value=''"&gt;&lt;/div&gt;
                                &lt;div class="bg right"&gt;&lt;/div&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="wrapper"&gt;
                        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                      &lt;input type="submit" class="button2" name="Go" value="GO"&gt;
                        &lt;/div&gt;
                    &lt;/form&gt;

                    &lt;/p&gt;
                &lt;/div&gt;
                &lt;p&gt;&amp;nbsp;&lt;/p&gt;
              &lt;h2&gt;&amp;nbsp;&lt;/h2&gt;
            &lt;/article&gt;
        &lt;/section&gt;
    &lt;!-- / content --&gt;
    &lt;/div&gt;
    &lt;div class="body2"&gt;
        &lt;div class="main"&gt;
    &lt;!--footer --&gt;
            &lt;footer&gt;
                Website template designed by &lt;a href="http://www.templatemonster.com/" target="_blank" rel="nofollow"&gt;www.templatemonster.com&lt;/a&gt;&lt;br&gt;
                3D Models provided by &lt;a href="http://www.templates.com/product/3d-models/" target="_blank" rel="nofollow"&gt;www.templates.com&lt;/a&gt;
            &lt;/footer&gt;
    &lt;!-- / footer --&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"&gt; Cufon.now(); &lt;/script&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>
