我已經創建了一個表單,用戶輸入他們的註冊詳細信息並使用查詢將其輸入到SQL數據庫中。然而,我輸入所有的細節,點擊提交,它返回一個服務器錯誤500. 我是新來綁定&執行,所以可能滑倒與mysqli線的格式。註冊表格返回服務器錯誤500
registrationsubmit.php
<font face="ClearSans-Thin">
<font color="lightgray">
<?php
include 'registrationform.php';
include 'connection.php';
?>
<center>
<?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.";
}
?>
</center>
你剛剛硬編碼的兄弟,是你檢查數據庫連接 –