Http 500 error with register page
-
500 is a generic error from the server. You'll need to debug it or get the details of the error.
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
Thanks for replying ZurdoDev. :) I was thinking it had to be something in the prepared statement that I have done wrong but can't figure it out. I ran a query to create the table and columns so assume that must be correct?
Somewhere you should be able to get the details of the error. I don't do much php but if you aren't seeing the error when you run it then maybe look in the logs.
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
Hi Could anyone help me with the following code? It was working fine until I inserted a username column in the DB table and edited this to suit (I thought) It gives an HTTP500 error page not working.
and180y wrote:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
...
mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);Two obvious problems: You're inserting into three columns, but you've only specified two values:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";
You've only specified types for two parameters, and you're missing a comma between the last two parameters:
mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
and180y wrote:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
...
mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);Two obvious problems: You're inserting into three columns, but you've only specified two values:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";
You've only specified types for two parameters, and you're missing a comma between the last two parameters:
mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
and180y wrote:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
...
mysqli_stmt_bind_param($stmt, "ss", $param_email, $param_username $param_password);Two obvious problems: You're inserting into three columns, but you've only specified two values:
$sql = "INSERT INTO users (email, username, password) VALUES (?, ?, ?)";
You've only specified types for two parameters, and you're missing a comma between the last two parameters:
mysqli_stmt_bind_param($stmt, "sss", $param_email, $param_username, $param_password);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I have played around starting again from the basic code and adding in what I need and checking for errors, all is fine till I put the code below in.
} // Validate email if(empty(trim($\_POST\["email"\]))){ $email\_err = "Please enter your email."; } elseif(strlen(trim($\_POST\["email"\])) < 6){ $email\_err = "email must have at least 6 characters."; } else{ $email = trim($\_POST\["email"\]); }
-
I have played around starting again from the basic code and adding in what I need and checking for errors, all is fine till I put the code below in.
} // Validate email if(empty(trim($\_POST\["email"\]))){ $email\_err = "Please enter your email."; } elseif(strlen(trim($\_POST\["email"\])) < 6){ $email\_err = "email must have at least 6 characters."; } else{ $email = trim($\_POST\["email"\]); }
-
if(empty(trim($_POST["email"]))){
If the email variable is blank then calling trim on it will fail. You should change it to:
if(empty($_POST["email"])){
-
Richard, is there an error log generated somewhere for the DB? I get an intermittent fault (loads of folk saying the can't register but I can see some are able to) This is the error that shows on the form so not of much use. lol "Something went wrong. Please try again later".
-
Richard, is there an error log generated somewhere for the DB? I get an intermittent fault (loads of folk saying the can't register but I can see some are able to) This is the error that shows on the form so not of much use. lol "Something went wrong. Please try again later".
-
Sorry, I don't know offhand. Check the MySQL documentation. I see that you are posting that message in your code. So you need to check why the call to
mysqli_stmt_execute
failed.Thanks Richard, I edited as you said the other night but wonder if my issue is somewhere in here?
if(empty($_POST["email"])){
$email_err = "Please enter your email.";
} elseif(strlen(trim($_POST["email"])) < 6){
$email_err = "email must have at least 6 characters.";
} else{
$email = trim($_POST["email"]);
}
} -
Sorry, I don't know offhand. Check the MySQL documentation. I see that you are posting that message in your code. So you need to check why the call to
mysqli_stmt_execute
failed.Thanks Richard, progress made. There is no error as such, if you try to register with the same email twice (yes I thought that as well) it throws the error I mentioned but isn't telling them the email is already registered. It does for username but the email was the bit I added in. :-)
-
Thanks Richard, progress made. There is no error as such, if you try to register with the same email twice (yes I thought that as well) it throws the error I mentioned but isn't telling them the email is already registered. It does for username but the email was the bit I added in. :-)
-
Did you not realise that you first need to check whether the email is already registered?