I am trying to put a signup.php section on my website. The script dies somewhere in the php code, and i've been trying to figure it out for hours with no luck.
The script dies somewhere in here because when i throw this in the file and ftp it to the server and run it, the page comes back blank.
//error handling
if((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)){
$message='Please insert all fields into the form below.';
}else{
if($pass1 != $pass2){
$message ='Your password fields do not match.';
}else{
//securing the values of the variables
$username = preg_replace("#[^0-9a-z]#i","",$username);
$fname = preg_replace("#[^0-9a-z]#i","",$fname);
$lname = preg_replace("#[^0-9a-z]#i","",$lname);
$pass1 = sha($pass1);
$email = mysql_real_escape_string($email);
//check duplicates
$user_query = mysql_query("SELECT username FROM members WHERE username='$username' LIMIT 1")or die("Could not check username");
$count_username = mysql_num_rows($user_query);
$user_query = mysql_query("SELECT email FROM members WHERE email='$email' LIMIT 1")or die("Could not check Email");
$count_email = mysql_num_rows($email_query);
Have you turned on error reporting? If so (or when you do), what error do you get when you post the form?
Not sure if your regular expressions in your preg_replace may be causing an issue as I am rubbish with them, but I have noticed that your password encryption is wrong, it should be
$email_query= mysql_query("SELECT email FROM members WHERE email='$email' LIMIT 1")or die("Could not check Email");
$count_email = mysql_num_rows($email_query);
Please change the variable assigned the 2nd mysql query from $user_query to $email_query. I hope this helps.
Thanks for the reply! I did fix the two errors you guys mentioned. When I turn errors on I get
"Parse error: syntax error, unexpected end of file in /home3/stevenp0/public_html/register2.php on line 75"
What is on line 75 (is there more code after what you have shown us as there aren't 75 lines in there). If not then you are missing 2 } at the end of your code.
Thank you again. I was missing the 2 ) but I think that was from lots of going back and forth, changing things over and over trying to figure out what exactly was wrong in the first place. The way I fixed it was to change the code structure just a bit so that the if/else if statements weren't inside other if/else if statements. I had always assumed that this was possible, or maybe there is a reason it doesn't work in my case, I'm not sure. If any other php noobies are having trouble with similar problems I hope this helps.
Bookmarks