|
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:
the code in do_signup.php is like this: -
<?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();
-
?>
-
-
any one can help me with this ? it is urgent as the project timeline is very near! thanks for any kind help!! :)
| |