472,780 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4. <link rel="stylesheet" type="text/css" href="gallery.css" />
  5.  
  6.  
  7. <script language="JavaScript">
  8.  
  9. <!--
  10.  
  11. function validate_form ( )
  12. {
  13.     valid = true;
  14.     if ( document.regForm.uName.value == "" )
  15.     {
  16.         alert ( "Please fill in the 'Your name' box." );
  17.         regForm.uName.focus();
  18.         valid = false;
  19.     }
  20.      else if ( ( document.regForm.gender[0].checked == false )
  21.     && ( document.regForm.gender[1].checked == false ) )
  22.     {
  23.         alert ( "Please choose your Gender: Male or Female" );
  24.         valid = false;
  25.     }
  26.     else if ( document.regForm.country.selectedIndex == 0 )
  27.         {
  28.                 alert ( "Please select your country." );
  29.                 regForm.country.focus();
  30.                 valid = false;
  31.         }
  32.  
  33.     else if ( document.regForm.age.selectedIndex == 0 )
  34.         {
  35.                 alert ( "Please select your Age." );
  36.                 regForm.age.focus();
  37.                 valid = false;
  38.         }
  39.  
  40.     else if ( document.regForm.email.value == "" )
  41.     {
  42.         alert ( "Please fill in the 'Your email' box." );
  43.         regForm.email.focus();
  44.         valid = false;
  45.     }  
  46.  
  47.     else if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(regForm.email.value))==false){
  48.         alert ( "The email address provided is not valid");
  49.         regForm.email.focus();
  50.         valid = false;
  51.     }
  52.     else if ( document.regForm.address.value == "" )
  53.     {
  54.         alert ( "Please fill in the 'Your address' box." );
  55.         regForm.address.focus();
  56.         valid = false;
  57.     }
  58.     else if( (/^\d{6}$/).test(regForm.postal.value) ==false){
  59.         alert ( "The postal code should have 6 digits");
  60.         regForm.postal.focus();
  61.         valid = false;
  62.  
  63.     }//postal codes
  64.  
  65.     else if( (/^[SG]\d{7}[A-Z]$/).test(regForm.nric.value) ==false){
  66.         alert ( "The nric is not valid"); //start with S OR G and end with a CAPITAL LETTER
  67.         regForm.nric.focus();
  68.         valid = false;
  69.     }//ic
  70.   else if( (/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/).test(regForm.pass1.value) ==false){
  71.         alert ( "The password is not valid"); //start with S OR G and end with a CAPITAL LETTER
  72.         regForm.pass1.focus();
  73.         valid = false;
  74.     }//ic
  75.  
  76.     else if( (regForm.pass1.value) != (regForm.pass2.value)) {
  77.         alert ( "Passwords do not match");
  78.         regForm.pass2.focus();
  79.         valid = false;
  80.     }//password match
  81.     else if ( document.regForm.secret.value == "" )
  82.     {
  83.         alert ( "Please fill in your Secret Question." );
  84.         regForm.secret.focus();
  85.         valid = false;
  86.     }  
  87.     else if ( document.regForm.answer.value == "" )
  88.     {
  89.         alert ( "Please fill in your Secret Answer." );
  90.         regForm.answer.focus();
  91.         valid = false;
  92.     }
  93.   else if ( ( document.regForm.Hphone.value=="" )
  94.     && ( document.regForm.HP.value =="") && ( document.regForm.Ophone.value == "") )
  95.     {
  96.         alert ( "Please enter any one of the three phone NO" );
  97.         valid = false;
  98.         }
  99.     else if ( ( document.regForm.Hphone.value!="" )&&((/^(\((\+\d{2})?\))?[56]\d{7}$/).test(regForm.Hphone.value) ==false)){
  100.         alert ( "the Home phone No entered is not valid" );
  101.         valid = false;
  102.         }
  103.  
  104.     else if (( document.regForm.HP.value !="")&&((/^(\((\+\d{2})?\))?[89]\d{7}$/).test(regForm.HP.value) ==false)){
  105.              alert ( "the HP phone No entered is not valid" );
  106.         valid = false;
  107.             }
  108.  
  109.     else if (( document.regForm.Ophone.value != "")&&((/^(\((\+\d{2})?\))?[3456]\d{7}$/).test(regForm.Ophone.value) ==false)){
  110.              alert ( "the Office phone No entered is not valid" );
  111.         valid = false;
  112.         }
  113.  
  114.  
  115.  
  116.     else if ( document.regForm.years.value == "" )
  117.     {
  118.         alert ( "please enter numerical value for No of years you played golf" );
  119.         regForm.years.focus();
  120.         valid = false;
  121.     }  
  122. else if( (/^((\d{1})|(\d{2}))$/).test(regForm.years.value) ==false){
  123.         alert ( "your input is incorrect,please enter numerical value");
  124.         regForm.years.focus();
  125.         valid = false;
  126.     }
  127.  
  128.     return valid;
  129. }
  130.  
  131.  
  132. //-->
  133. </script>
  134.  
  135.  
  136.  
  137. </head>
  138. <body>
  139. <div id="header">
  140. </div>
  141. <div id="leftcol">    
  142. </div>
  143. <div id="maincol">
  144.     <form name = 'regForm' action = "do_signup.php" method = "POST" onSubmit = 'return validate_form ();'>
  145.          <? echo "<br>";?>
  146.          <table>
  147.          <tr>
  148.   <td> <font size="4"color="red">*</font> User Name </td><td><input type = "text" name="uName"> </td>
  149.     <td>
  150.     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="4"color="red">*</font>please enter one or more of the following Phone NO:</td>
  151.    </tr>
  152.  
  153.  
  154.     <tr>
  155.     <td class="tablebody1"><font size="4"color="red">*</font>Gender:<BR>
  156. </td>
  157.  
  158. <td class="tablebody1">
  159. <input name="gender" type="radio" value="male" />
  160.  Male&nbsp;&nbsp;&nbsp;&nbsp;
  161. <input name="gender" type="radio" value="female" />
  162. Female</td>
  163.  
  164.  
  165.     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Home Phone&nbsp;&nbsp;&nbsp;&nbsp;<input type = "text" id="1" name="Hphone"></td>
  166.  
  167. </tr>
  168.  
  169.  <tr>
  170.                 <td class="loginFormLabel"><font size="4"color="red">*</font>    <span class="error"><nobr>Country:</nobr></span>
  171. </td>
  172.                 <td class="formFieldSmall">
  173.                     <select name="country" tabindex="11">
  174.                             <option value="---">---</option>
  175.                             <option value="Indonesia" >Indonesia  </option>
  176.                             <option value="Malaysia" >Malaysia  </option>
  177.                             <option value="Philippines" >Philippines   </option>
  178.                             <option value="Singapore" > Singapore </option>
  179.                             <option value="Thailand" > Thailand</option>
  180.                             <option value="Vietnam " > Vietnam  </option>
  181.                             <option value="Laos" >Laos </option>
  182.                             <option value="Myanmar" > Myanmar </option>
  183.                             <option value="Cambodia" > Cambodia </option>
  184.                             <option value="Brunei" > Brunei </option>
  185.  
  186.                     </select>
  187.                     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hand Phone&nbsp;&nbsp;&nbsp;&nbsp;  <input type = "text" id="2" name="HP"></td>
  188. </td>
  189. </tr>
  190.            <tr>
  191.         <td class="loginFormLabel"><font size="4"color="red">*</font>    <span class="error"><nobr>Your age:</nobr></span>
  192. </td>
  193.                 <td class="formFieldSmall">
  194.                 <select name="age">
  195.                             <option value="---">---</option>
  196.                             <option value="15-25">15-25 years</option>
  197.                             <option value="26-35">26-35 years</option>
  198.                             <option value="36-45">36-45 years</option>
  199.                             <option value="46-60">46-60 years</option>
  200.                             <option value="60+">60+ years</option>
  201.                             </select>
  202.                 </td>
  203.             <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Office Phone&nbsp;&nbsp;&nbsp; <input type = "text" id="3" name="Ophone"></td>
  204.  
  205.  
  206.             </tr>
  207.     <tr>
  208.     <td><font size="4"color="red">*</font>Email Address </td> <td><input type = "text" name="email"></td> 
  209.     </tr>
  210.     <tr>
  211.     <td><font size="4"color="red">*</font>Address </td> <td><input type = "text" name="address"></td> 
  212.     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="4"color="red">*</font>please enter No of years you played golf:</td>
  213.     </tr>
  214.     <tr>
  215.     <td><font size="4"color="red">*</font>Postal Code </td> <td><input type = "text" name="postal"></td>
  216.     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No of years:&nbsp;&nbsp;&nbsp;&nbsp; <input type = "text"size="2" name="years"> years</td>
  217.     </tr>
  218.  
  219.     <tr>
  220.     <td><font size="4"color="red">*</font>FIN/IC Number </td> <td><input type = "text" name="nric"></td>
  221.     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>(Please enter in numerical figures)&nbsp;&nbsp;&nbsp;&nbsp;</i></td>
  222.     </tr>
  223.     <tr>
  224.     <td><font size="4"color="red">*</font>Password </td> <td><input type = "password" name="pass1"></td></tr>
  225.     <tr><td><font size="4"color="red">*</font>Confirm Password</td><td><input type = "password" name="pass2"></td></tr>
  226.  
  227.     <tr>
  228.     <td><font size="4"color="red">*</font>Your Secret Question </td> <td><input type = "text" name="secret"></td>
  229.     </tr>
  230.     <tr>
  231.     <td><font size="4"color="red">*</font>Your Secret Answer </td> <td><input type = "text" name="answer"></td>
  232.     </tr>
  233.     </table>
  234.     <input type ="submit" value="submit">
  235.  
  236.  
  237. <?
  238.     echo"<br>";
  239.     echo"<br>";
  240.     echo"<br>";
  241.     echo"<br>";
  242.  
  243.     echo" NOTE:";
  244.     echo"<br>";
  245.     echo " * Password must be at least 8 characters";
  246.     echo"<br>";
  247.     echo "* Password must contain at least one one lower case letter, one upper case letter, one digit and one special character";
  248.     echo"<br>";
  249.     echo "* Valid special characters (which are configurable) are   '@#$%^&+='";
  250.     echo"<br>";
  251.     ?>
  252.  
  253. </form>
  254. </div>
  255. </body>
  256. </html>
  257.  
  258.  

the code in do_signup.php is like this:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ob_start();
  3. session_start();
  4. require('db.php');
  5. //retrieve info from from
  6. $usr = $_POST['uName'];
  7. $gender=$_POST['gender'];
  8. $country=$_POST['country'];
  9. $age=$_POST['age'];
  10. $eml =  $_POST['email'];
  11. $addr = $_POST['address'];
  12. $pCode = $_POST['postal'];
  13. $phone = $_POST['Hphone'];
  14. $HP = $_POST['HP'];
  15. $OP = $_POST['Ophone'];
  16. $nric = $_POST['nric'];
  17. $years=$_POST['years'];
  18. $pass1 = $_POST['pass1'];
  19. $pass2 = $_POST['pass2'];
  20. $secret=$_POST['secret'];
  21. $answer=$_POST['answer'];
  22.  
  23. $_SESSION['username']=$usr;
  24. $_SESSION['gender']=$gender;
  25. $_SESSION['country']=$country;
  26. $_SESSION['age']=$age;
  27. $_SESSION['email']=$eml;
  28. $_SESSION['address']=$address;
  29. $_SESSION['postal']=$pCode;
  30. $_SESSION['Hphone']=$phone;
  31. $_SESSION['HP']=$HP;
  32. $_SESSION['Ophone']=$OP;
  33. $_SESSION['nric']=$nric;
  34. $_SESSION['years']=$years;
  35. $_SESSION['pass1']=$pass1;
  36. $_SESSION['pass2']=$pass2;
  37. $_SESSION['secret']=$secret;
  38. $_SESSION['answer']=$answer;
  39.  
  40. if ($_POST['uName'] == “”){ 
  41. echo 'you did not fill in your name';
  42. }
  43. else if ($_POST['gender'] == “”){ 
  44. echo 'you did not choose your gender';
  45. }
  46. else if ($_POST['country'] == “”){ 
  47. echo 'you did not choose your country';
  48. }
  49. else if ($_POST['age'] == “”){ 
  50. echo 'you did not choose your age';
  51. }
  52. else if ($_POST['email'] == “”){ 
  53. echo 'you did not fill in your email';
  54. }
  55.  
  56. else if ($_POST['address'] == “”){ 
  57. echo 'you did not fill in your address';
  58. }
  59.  
  60. else if ($_POST['postal'] == “”){ 
  61. echo'you did not fill in your postal';
  62. }
  63.  
  64. else if ($_POST['nric'] == “”){ 
  65. echo'you did not fill in your nric';
  66. }
  67. else if ($_POST['years'] == “”){ 
  68. echo'you did not fill in how many years you played golf';
  69. }
  70. else if ($_POST['pass1'] == “”){ 
  71. echo'you did not fill in your password';
  72. }
  73. else if ($_POST['pass1']!=$_POST['pass2']){ 
  74. echo'your password did not match!';
  75. }
  76. else if ($_POST['secret'] == “”){ 
  77. echo'you did not fill in your secret question';
  78. }
  79. else if ($_POST['answer'] == “”){ 
  80. echo'you did not fill in your secret answer';
  81. }
  82. //Encrypt password
  83. $pwd = MD5($pass1);
  84.  
  85. //Connect to Database server
  86. mysql_connect(MACHINE, USER, '');
  87. mysql_select_db(DBNAME);
  88.  
  89. //SQL statement to insert member record
  90.  
  91.  
  92. $sql2="Select * from users where nric='" . $nric . "'";
  93. $result2= mysql_query($sql2);
  94.  
  95.  
  96. if(mysql_num_rows($result2) == 1)
  97. {
  98. echo" your NRIC is deupicated in our database, please re-signup";
  99. echo"<br>";
  100. echo "Error: could not add you as a member ";
  101. echo"<br>";
  102. //echo "<a href = 'signupform.php'>Go back to re-signup</a>";
  103. echo "you will be redirected to our signup page to re-enter your NRIC";
  104. //echo "<a href = 'update.php'>Renter your nric</a>";
  105. header("Refresh: 5; URL=signupform.php");
  106. }
  107. else{
  108. $sql = "INSERT INTO users (id, name, gender, country, age, password,secret,answer, email, address, postal_code, Hphone, HP, Ophone, nric,years) VALUES ";
  109. $sql .= "('','".$usr."','".$gender."','".$country."','".$age."','".$pwd."','".$secret."','".$answer."','".$eml."','".$addr."','".$pCode."','".$phone."','".$HP."','".$Ophone."','".$nric."','".$years."')";
  110. mysql_query($sql);
  111.  
  112.     $fromHeader = "From:"."feedback@postergolf.sg";
  113.     $subject = "Welcome to the Golf Connect";
  114.     $msg = "Your user name:". $usr." and password:".$pass1;
  115.  
  116.     mail($eml, $subject, $msg, $fromHeader );
  117.     echo"<br>";
  118.     echo " Confirmation Email has been sent to" .$usr."<br>";
  119.     echo "Member ". $usr. " was successfully added!<br>";
  120.     header("Refresh: 5; URL=index.php");
  121.     echo "Redirecting to index.php"; //redirecting is done above!
  122. }
  123.  
  124.  
  125.  
  126. //echo $num_rows;
  127. //Add new user to database table
  128. /*if ($num_rows==1){
  129.     //show confirmation message upon success
  130.  
  131.  
  132.     //Emailing
  133.     $fromHeader = "From:"."feedback@postergolf.sg";
  134.     $subject = "Welcome to the Golf Connect";
  135.     $msg = "Your user name:". $usr." and password:".$pass1;
  136.  
  137.     mail($eml, $subject, $msg, $fromHeader );
  138.     echo"<br>";
  139.     echo " Confirmation Email has been sent to" .$usr."<br>";
  140.     echo "Member ". $usr. " was successfully added!<br>";
  141.     echo "Redirecting to index.php"; //redirecting is done above!
  142.     //header("Refresh: 5; URL=index.php");
  143.     //echo "<a href = 'index.php'>Go back to home page</a>";
  144. }//end if
  145. else{
  146.     echo "Error: could not add you as a member ";
  147. }//end else*/
  148. //ob_end_flush();
  149. ?>
  150.  
  151.  
any one can help me with this ? it is urgent as the project timeline is very near! thanks for any kind help!! :)
Jul 14 '07 #1
1 3008
pbmods
5,821 Expert 4TB
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.
Jul 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: info | last post by:
This is to announce the inaugural meeting of the Philadelphia XML Users Group. If you're in the Philadelphia area, and you have an interest in XML and related standards in publishing, you're...
0
by: Kenneth Baltrinic | last post by:
Is the following code correct for serializing a quasi-single class, that is a class that has a descreet (though more than one, so not a true singleton) number of static instances and no dynamically...
1
by: VB Programmer | last post by:
I am using personalization/profile to store info for the user that is not contained in the aspnet_Users or aspnet_Membership tables. This info includes, firstname, lastname, and phonenumber. ...
9
by: warezguy05 | last post by:
Hello I'm experiencing a problem; I've written a small script where volunteers can be booked for work-activities at a festival. The festival has 5 different departments so i've created a...
5
by: PaulPay | last post by:
I want to add a newsletter signup form to my ASP website and then have the newsletter automatically emailed to the client. I want to use a hosted email/autorresponder company because of the spam...
1
by: kang jia | last post by:
hi 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...
2
by: nazgul42 | last post by:
Ok... this is my third problem today, but here goes: On my signup page for my login system on my website, I have some code that is supposed to check if a username is already taken and give an error...
2
by: whitey | last post by:
Can anybody supply me with a script the does what is in the title above please? I have tried so many different methods! here is what im currently trying to get to work SIGN IN <!doctype...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.