currently i am editing signup page, when user enter deupicated NRIC and click signup, they will go to do_signuppage and read the error message and then after 5 seconds, they will be redirected to signup page again, however, this time they go back, all the correct value will be remain. how should i achieve this.
my current code for singup.php is like this
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="gallery.css" />
- <script language="JavaScript">
- <!--
- function validate_form ( )
- {
- valid = true;
- if ( document.regForm.uName.value == "" )
- {
- alert ( "Please fill in the 'Your name' box." );
- regForm.uName.focus();
- valid = false;
- }
- else if ( ( document.regForm.gender[0].checked == false )
- && ( document.regForm.gender[1].checked == false ) )
- {
- alert ( "Please choose your Gender: Male or Female" );
- valid = false;
- }
- else if ( document.regForm.country.selectedIndex == 0 )
- {
- alert ( "Please select your country." );
- regForm.country.focus();
- valid = false;
- }
- else if ( document.regForm.age.selectedIndex == 0 )
- {
- alert ( "Please select your Age." );
- regForm.age.focus();
- valid = false;
- }
- else if ( document.regForm.email.value == "" )
- {
- alert ( "Please fill in the 'Your email' box." );
- regForm.email.focus();
- valid = false;
- }
- else if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(regForm.email.value))==false){
- alert ( "The email address provided is not valid");
- regForm.email.focus();
- valid = false;
- }
- else if ( document.regForm.address.value == "" )
- {
- alert ( "Please fill in the 'Your address' box." );
- regForm.address.focus();
- valid = false;
- }
- else if( (/^\d{6}$/).test(regForm.postal.value) ==false){
- alert ( "The postal code should have 6 digits");
- regForm.postal.focus();
- valid = false;
- }//postal codes
- else if( (/^[SG]\d{7}[A-Z]$/).test(regForm.nric.value) ==false){
- alert ( "The nric is not valid"); //start with S OR G and end with a CAPITAL LETTER
- regForm.nric.focus();
- valid = false;
- }//ic
- else if( (/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/).test(regForm.pass1.value) ==false){
- alert ( "The password is not valid"); //start with S OR G and end with a CAPITAL LETTER
- regForm.pass1.focus();
- valid = false;
- }//ic
- else if( (regForm.pass1.value) != (regForm.pass2.value)) {
- alert ( "Passwords do not match");
- regForm.pass2.focus();
- valid = false;
- }//password match
- else if ( document.regForm.secret.value == "" )
- {
- alert ( "Please fill in your Secret Question." );
- regForm.secret.focus();
- valid = false;
- }
- else if ( document.regForm.answer.value == "" )
- {
- alert ( "Please fill in your Secret Answer." );
- regForm.answer.focus();
- valid = false;
- }
- else if ( ( document.regForm.Hphone.value=="" )
- && ( document.regForm.HP.value =="") && ( document.regForm.Ophone.value == "") )
- {
- alert ( "Please enter any one of the three phone NO" );
- valid = false;
- }
- else if ( ( document.regForm.Hphone.value!="" )&&((/^(\((\+\d{2})?\))?[56]\d{7}$/).test(regForm.Hphone.value) ==false)){
- alert ( "the Home phone No entered is not valid" );
- valid = false;
- }
- else if (( document.regForm.HP.value !="")&&((/^(\((\+\d{2})?\))?[89]\d{7}$/).test(regForm.HP.value) ==false)){
- alert ( "the HP phone No entered is not valid" );
- valid = false;
- }
- else if (( document.regForm.Ophone.value != "")&&((/^(\((\+\d{2})?\))?[3456]\d{7}$/).test(regForm.Ophone.value) ==false)){
- alert ( "the Office phone No entered is not valid" );
- valid = false;
- }
- else if ( document.regForm.years.value == "" )
- {
- alert ( "please enter numerical value for No of years you played golf" );
- regForm.years.focus();
- valid = false;
- }
- else if( (/^((\d{1})|(\d{2}))$/).test(regForm.years.value) ==false){
- alert ( "your input is incorrect,please enter numerical value");
- regForm.years.focus();
- valid = false;
- }
- return valid;
- }
- //-->
- </script>
- </head>
- <body>
- <div id="header">
- </div>
- <div id="leftcol">
- </div>
- <div id="maincol">
- <form name = 'regForm' action = "do_signup.php" method = "POST" onSubmit = 'return validate_form ();'>
- <? echo "<br>";?>
- <table>
- <tr>
- <td> <font size="4"color="red">*</font> User Name </td><td><input type = "text" name="uName"> </td>
- <td>
- <font size="4"color="red">*</font>please enter one or more of the following Phone NO:</td>
- </tr>
- <tr>
- <td class="tablebody1"><font size="4"color="red">*</font>Gender:<BR>
- </td>
- <td class="tablebody1">
- <input name="gender" type="radio" value="male" />
- Male
- <input name="gender" type="radio" value="female" />
- Female</td>
- <td> Home Phone <input type = "text" id="1" name="Hphone"></td>
- </tr>
- <tr>
- <td class="loginFormLabel"><font size="4"color="red">*</font> <span class="error"><nobr>Country:</nobr></span>
- </td>
- <td class="formFieldSmall">
- <select name="country" tabindex="11">
- <option value="---">---</option>
- <option value="Indonesia" >Indonesia </option>
- <option value="Malaysia" >Malaysia </option>
- <option value="Philippines" >Philippines </option>
- <option value="Singapore" > Singapore </option>
- <option value="Thailand" > Thailand</option>
- <option value="Vietnam " > Vietnam </option>
- <option value="Laos" >Laos </option>
- <option value="Myanmar" > Myanmar </option>
- <option value="Cambodia" > Cambodia </option>
- <option value="Brunei" > Brunei </option>
- </select>
- <td> Hand Phone <input type = "text" id="2" name="HP"></td>
- </td>
- </tr>
- <tr>
- <td class="loginFormLabel"><font size="4"color="red">*</font> <span class="error"><nobr>Your age:</nobr></span>
- </td>
- <td class="formFieldSmall">
- <select name="age">
- <option value="---">---</option>
- <option value="15-25">15-25 years</option>
- <option value="26-35">26-35 years</option>
- <option value="36-45">36-45 years</option>
- <option value="46-60">46-60 years</option>
- <option value="60+">60+ years</option>
- </select>
- </td>
- <td> Office Phone <input type = "text" id="3" name="Ophone"></td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>Email Address </td> <td><input type = "text" name="email"></td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>Address </td> <td><input type = "text" name="address"></td>
- <td> <font size="4"color="red">*</font>please enter No of years you played golf:</td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>Postal Code </td> <td><input type = "text" name="postal"></td>
- <td> No of years: <input type = "text"size="2" name="years"> years</td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>FIN/IC Number </td> <td><input type = "text" name="nric"></td>
- <td> <i>(Please enter in numerical figures) </i></td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>Password </td> <td><input type = "password" name="pass1"></td></tr>
- <tr><td><font size="4"color="red">*</font>Confirm Password</td><td><input type = "password" name="pass2"></td></tr>
- <tr>
- <td><font size="4"color="red">*</font>Your Secret Question </td> <td><input type = "text" name="secret"></td>
- </tr>
- <tr>
- <td><font size="4"color="red">*</font>Your Secret Answer </td> <td><input type = "text" name="answer"></td>
- </tr>
- </table>
- <input type ="submit" value="submit">
- <?
- echo"<br>";
- echo"<br>";
- echo"<br>";
- echo"<br>";
- echo" NOTE:";
- echo"<br>";
- echo " * Password must be at least 8 characters";
- echo"<br>";
- echo "* Password must contain at least one one lower case letter, one upper case letter, one digit and one special character";
- echo"<br>";
- echo "* Valid special characters (which are configurable) are '@#$%^&+='";
- echo"<br>";
- ?>
- </form>
- </div>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <?php
- ob_start();
- session_start();
- require('db.php');
- //retrieve info from from
- $usr = $_POST['uName'];
- $gender=$_POST['gender'];
- $country=$_POST['country'];
- $age=$_POST['age'];
- $eml = $_POST['email'];
- $addr = $_POST['address'];
- $pCode = $_POST['postal'];
- $phone = $_POST['Hphone'];
- $HP = $_POST['HP'];
- $OP = $_POST['Ophone'];
- $nric = $_POST['nric'];
- $years=$_POST['years'];
- $pass1 = $_POST['pass1'];
- $pass2 = $_POST['pass2'];
- $secret=$_POST['secret'];
- $answer=$_POST['answer'];
- $_SESSION['username']=$usr;
- $_SESSION['gender']=$gender;
- $_SESSION['country']=$country;
- $_SESSION['age']=$age;
- $_SESSION['email']=$eml;
- $_SESSION['address']=$address;
- $_SESSION['postal']=$pCode;
- $_SESSION['Hphone']=$phone;
- $_SESSION['HP']=$HP;
- $_SESSION['Ophone']=$OP;
- $_SESSION['nric']=$nric;
- $_SESSION['years']=$years;
- $_SESSION['pass1']=$pass1;
- $_SESSION['pass2']=$pass2;
- $_SESSION['secret']=$secret;
- $_SESSION['answer']=$answer;
- if ($_POST['uName'] == “”){
- echo 'you did not fill in your name';
- }
- else if ($_POST['gender'] == “”){
- echo 'you did not choose your gender';
- }
- else if ($_POST['country'] == “”){
- echo 'you did not choose your country';
- }
- else if ($_POST['age'] == “”){
- echo 'you did not choose your age';
- }
- else if ($_POST['email'] == “”){
- echo 'you did not fill in your email';
- }
- else if ($_POST['address'] == “”){
- echo 'you did not fill in your address';
- }
- else if ($_POST['postal'] == “”){
- echo'you did not fill in your postal';
- }
- else if ($_POST['nric'] == “”){
- echo'you did not fill in your nric';
- }
- else if ($_POST['years'] == “”){
- echo'you did not fill in how many years you played golf';
- }
- else if ($_POST['pass1'] == “”){
- echo'you did not fill in your password';
- }
- else if ($_POST['pass1']!=$_POST['pass2']){
- echo'your password did not match!';
- }
- else if ($_POST['secret'] == “”){
- echo'you did not fill in your secret question';
- }
- else if ($_POST['answer'] == “”){
- echo'you did not fill in your secret answer';
- }
- //Encrypt password
- $pwd = MD5($pass1);
- //Connect to Database server
- mysql_connect(MACHINE, USER, '');
- mysql_select_db(DBNAME);
- //SQL statement to insert member record
- $sql2="Select * from users where nric='" . $nric . "'";
- $result2= mysql_query($sql2);
- if(mysql_num_rows($result2) == 1)
- {
- echo" your NRIC is deupicated in our database, please re-signup";
- echo"<br>";
- echo "Error: could not add you as a member ";
- echo"<br>";
- //echo "<a href = 'signupform.php'>Go back to re-signup</a>";
- echo "you will be redirected to our signup page to re-enter your NRIC";
- //echo "<a href = 'update.php'>Renter your nric</a>";
- header("Refresh: 5; URL=signupform.php");
- }
- else{
- $sql = "INSERT INTO users (id, name, gender, country, age, password,secret,answer, email, address, postal_code, Hphone, HP, Ophone, nric,years) VALUES ";
- $sql .= "('','".$usr."','".$gender."','".$country."','".$age."','".$pwd."','".$secret."','".$answer."','".$eml."','".$addr."','".$pCode."','".$phone."','".$HP."','".$Ophone."','".$nric."','".$years."')";
- mysql_query($sql);
- $fromHeader = "From:"."feedback@postergolf.sg";
- $subject = "Welcome to the Golf Connect";
- $msg = "Your user name:". $usr." and password:".$pass1;
- mail($eml, $subject, $msg, $fromHeader );
- echo"<br>";
- echo " Confirmation Email has been sent to" .$usr."<br>";
- echo "Member ". $usr. " was successfully added!<br>";
- header("Refresh: 5; URL=index.php");
- echo "Redirecting to index.php"; //redirecting is done above!
- }
- //echo $num_rows;
- //Add new user to database table
- /*if ($num_rows==1){
- //show confirmation message upon success
- //Emailing
- $fromHeader = "From:"."feedback@postergolf.sg";
- $subject = "Welcome to the Golf Connect";
- $msg = "Your user name:". $usr." and password:".$pass1;
- mail($eml, $subject, $msg, $fromHeader );
- echo"<br>";
- echo " Confirmation Email has been sent to" .$usr."<br>";
- echo "Member ". $usr. " was successfully added!<br>";
- echo "Redirecting to index.php"; //redirecting is done above!
- //header("Refresh: 5; URL=index.php");
- //echo "<a href = 'index.php'>Go back to home page</a>";
- }//end if
- else{
- echo "Error: could not add you as a member ";
- }//end else*/
- //ob_end_flush();
- ?>
can anyone help me with this, it is urgent, as project time is very near. thanks in advance for the help :)