Thursday, September 19, 2019

php - Registration form returning Server Error 500

I've created a form where users input their registration details and it enters it into an SQL database using a query. However, I type in all the details, click submit and it return a server error 500.
I'm new to binding & executing so probably slipped up with the format of the mysqli lines.


registrationsubmit.php




include 'registrationform.php';
include 'connection.php';
?>

if (isset($_POST['regsubmit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$user = $_POST['username'];
$pass = $_POST['password'];
if ($stmt = mysqli_prepare($dbhandle, $query = "INSERT INTO users (FirstName, LastName, Username, Password) VALUES (?,?,?,?)")) {
mysqli_stmt_bind_param($stmt, 'ssss', $firstname,$lastname,$user,$pass);
mysqli_stmt_execute($stmt) or die('This username is already in use - Please choose another one');
}else{
die('Error when preparing '.mysqli_error($dbhandle));
}
Echo "Registration Successful - Press the Home button to return to the homepage.";
}
?>

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...