how to remain correct user info in signup page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kang jia
    New Member
    • Jun 2007
    • 88

    #1

    how to remain correct user info in signup page

    hi

    when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page again to re-signup, however, i would like to remain all the correct infromation, and let users re-entered their NRIC. how can i do this. can i use Session, but it seems cant work. any one can help me?

    my code in signup page is like this:

    [code=PHP]

    <html>
    <head>
    <link rel="stylesheet " type="text/css" href="gallery.c ss" />


    <script language="JavaS cript">

    <!--

    function validate_form ( )
    {
    valid = true;
    if ( document.regFor m.uName.value == "" )
    {
    alert ( "Please fill in the 'Your name' box." );
    regForm.uName.f ocus();
    valid = false;
    }
    else if ( ( document.regFor m.gender[0].checked == false )
    && ( document.regFor m.gender[1].checked == false ) )
    {
    alert ( "Please choose your Gender: Male or Female" );
    valid = false;
    }
    else if ( document.regFor m.country.selec tedIndex == 0 )
    {
    alert ( "Please select your country." );
    regForm.country .focus();
    valid = false;
    }

    else if ( document.regFor m.age.selectedI ndex == 0 )
    {
    alert ( "Please select your Age." );
    regForm.age.foc us();
    valid = false;
    }

    else if ( document.regFor m.email.value == "" )
    {
    alert ( "Please fill in the 'Your email' box." );
    regForm.email.f ocus();
    valid = false;
    }

    else if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3 })+$/.test(regForm.e mail.value))==f alse){
    alert ( "The email address provided is not valid");
    regForm.email.f ocus();
    valid = false;
    }
    else if ( document.regFor m.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.fo cus();
    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.f ocus();
    valid = false;
    }//ic

    else if( (regForm.pass1. value) != (regForm.pass2. value)) {
    alert ( "Passwords do not match");
    regForm.pass2.f ocus();
    valid = false;
    }//password match
    else if ( document.regFor m.secret.value == "" )
    {
    alert ( "Please fill in your Secret Question." );
    regForm.secret. focus();
    valid = false;
    }
    else if ( document.regFor m.answer.value == "" )
    {
    alert ( "Please fill in your Secret Answer." );
    regForm.answer. focus();
    valid = false;
    }
    else if ( ( document.regFor m.Hphone.value= ="" )
    && ( document.regFor m.HP.value =="") && ( document.regFor m.Ophone.value == "") )
    {
    alert ( "Please enter any one of the three phone NO" );
    valid = false;
    }
    else if ( ( document.regFor m.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.regFor m.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.regFor m.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.regFor m.years.value == "" )
    {
    alert ( "please enter numerical value for No of years you played golf" );
    regForm.years.f ocus();
    valid = false;
    }
    else if( (/^((\d{1})|(\d{2 }))$/).test(regForm. years.value) ==false){
    alert ( "your input is incorrect,pleas e enter numerical value");
    regForm.years.f ocus();
    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>
    &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; <font size="4"color=" red">*</font>please enter one or more of the following Phone NO:</td>
    </tr>


    <tr>
    <td class="tablebod y1"><font size="4"color=" red">*</font>Gender:<BR >
    </td>

    <td class="tablebod y1">
    <input name="gender" type="radio" value="male" />
    Male&nbsp;&nbsp ;&nbsp;&nbsp;
    <input name="gender" type="radio" value="female" />
    Female</td>


    <td>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;Home Phone&nbsp;&nbs p;&nbsp;&nbsp;< input type = "text" id="1" name="Hphone"></td>

    </tr>

    <tr>
    <td class="loginFor mLabel"><font size="4"color=" red">*</font> <span class="error">< nobr>Country:</nobr></span>
    </td>
    <td class="formFiel dSmall">
    <select name="country" tabindex="11">
    <option value="---">---</option>
    <option value="Indonesi a" >Indonesia </option>
    <option value="Malaysia " >Malaysia </option>
    <option value="Philippi nes" >Philippines </option>
    <option value="Singapor e" > 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>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;Hand Phone&nbsp;&nbs p;&nbsp;&nbsp; <input type = "text" id="2" name="HP"></td>
    </td>
    </tr>
    <tr>
    <td class="loginFor mLabel"><font size="4"color=" red">*</font> <span class="error">< nobr>Your age:</nobr></span>
    </td>
    <td class="formFiel dSmall">
    <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>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;Office Phone&nbsp;&nbs p;&nbsp; <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>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;<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>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;No of years:&nbsp;&nb sp;&nbsp;&nbsp; <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>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;<i>(Please enter in numerical figures)&nbsp;& nbsp;&nbsp;&nbs p;</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>

    [/code]


    the code in do_signup.php is like this:

    [code=PHP]
    <?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(M ACHINE, USER, '');
    mysql_select_db (DBNAME);

    //SQL statement to insert member record


    $sql2="Select * from users where nric='" . $nric . "'";
    $result2= mysql_query($sq l2);


    if(mysql_num_ro ws($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'>Re nter 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."','".$secr et."','".$answe r."','".$eml."' ,'".$addr."','" .$pCode."','".$ phone."','".$HP ."','".$Ophone. "','".$nric."', '".$years."' )";
    mysql_query($sq l);

    $fromHeader = "From:"."feedba ck@postergolf.s g";
    $subject = "Welcome to the Golf Connect";
    $msg = "Your user name:". $usr." and password:".$pas s1;

    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 "Redirectin g 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:"."feedba ck@postergolf.s g";
    $subject = "Welcome to the Golf Connect";
    $msg = "Your user name:". $usr." and password:".$pas s1;

    mail($eml, $subject, $msg, $fromHeader );
    echo"<br>";
    echo " Confirmation Email has been sent to" .$usr."<br>";
    echo "Member ". $usr. " was successfully added!<br>";
    echo "Redirectin g 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();
    ?>

    [/code]

    any one can help me with this ? it is urgent as the project timeline is very near! thanks for any kind help!! :)
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Kang.

    What is your code doing that you don't want it to do? Give an example.
    What is your code *not* doing that it is supposed to? Give an example.

    Comment

    Working...