Member Avatar for moha_1990

I'm doing a registration page. it require the name, password, email, gender, nationality, date of birth and other things.

I did the registration and it was good. but I need to add the validation and this is what I could do so far, so please if you could help me with the validation

<?php include("config.php"); ?>
    <!DOCTYPE html>
    <html lang="en">

    <!-- CSS -->
    <link rel="stylesheet" href="css/styles.css" type="text/css"/>
    <link type="text/css" href="css/jquery-ui-1.7.2.custom.css" rel="stylesheet" /> 

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

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





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

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

                        <div class="wrapper">
                            User Name:
                            <div class="bg"><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=''"></div>
                        </div>
                    <div class="wrapper">
                            Password:
                            <div class="bg"><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=''"></div>
                      </div>
                      <div class="wrapper">

                        <h2 id="coq"> <a href="Forget.php">Forget Password</a></h2>

                          <input type="submit" class="button2" value="GO">
                    </div>
                    </form>



                    <h2> </h2>
                </div>
            </article>
            <article class="col2 pad_left1">
                <h2>Registration</h2>
                <div class="wrapper">
                    <figure class="left marg_right1"></figure>
                    <p> 

                                    <form id="form_1" action="" method="post">
    <div class="wrapperr"  >
    <?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)<3)){
    echo "The username is too short"."</br>";


    if((strlen($gender)<3)){
    echo "Gender"."</br>";
    }


    if((strlen($Cou)<2)){
    echo "The CO too short"."</br>";
    }


    if((strlen($phone)<5)){
    echo "The phone is too short"."</br>";
    }

    if((strlen($password)<5)){
    echo "The password is too short"."</br>";
    }
    }
    else{
    if($password == $repassword){
    $chec = mysql_query("SELECT * FROM register WHERE name='$username'"); 
    if(strlen($chec['name'])>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 <a href='index.php'> here </a> to home";
    }
    else{
    echo "email is invalid";
    }
    }
    }
    else{
    echo "The password in both field doesn't match.";
    }
    }
    }






    ?>
        </div>              <div class="wrapper">
                            Name:
                            <div class="bg"><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=''"></div>
                        </div>

                                            <div class="wrapper">
                            Password:
                            <div class="bg"><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=''"></div>
                        </div>


                                            <div class="wrapper">
                            Confirm password:
                            <div class="bg"><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=''"></div>
                        </div>

                                            <div class="wrapper">
                            e-mail:
                            <div class="bg"><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=''"></div>
                        </div>


                        <div class="wrapper">
                            Gender:
                            <div class="bg">
                              <td>
                              <input type="radio" name="T5" value="Male">
                              Male
                              </td><td>
                               <input type="radio" name="T5" value="Female">
                              Female</td>


                          </div>
                        </div>


                                    <div class="wrapper">
                            NATIONALITY:
                              <div class="bg"><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=''"></div>
                        </div>


                        <div class="wrapper">

                                                        <div class="wrapper">
                            Passport number:
                              <div class="bg"><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=''"></div>
                        </div>


                        <div class="wrapper">


                            Date of birth:
                      <div class="wrapper">
                                <div class="bg left"><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"  >
                                  <br/><span id="bdayInfo"></span>

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

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

Recommended Answers

All 3 Replies

Member Avatar for diafol

You seem to be using unsanitized post vars in your sql. You must clean them.
You don't mention what aspects of the validation you need help with. Just dumping almost 300 lines of markup and code won't help.

Member Avatar for moha_1990

could you please tell me how I can contact you ?

Im gonna send you, the code, and the database file

my major project discussion will be this tuesday
and i still cant add the validation for the registeration form

Member Avatar for diafol

No. I have no interest in receiving work from you. Any help you need will be via the forum. We'll help you with SPECIFIC questions. So, focus on the bit of code you need help with. Tuseday. Oh dear. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.