2015-10-20 46 views
0

我已經創建了一個表單,用戶輸入他們的註冊詳細信息並使用查詢將其輸入到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> 
+0

你剛剛硬編碼的兄弟,是你檢查數據庫連接 –

回答

0

如果你仔細看,你會發現多餘的變量賦值。嘗試使用這個:

$stmt = mysqli_prepare($dbhandle, "INSERT INTO users (FirstName, LastName, Username, Password) VALUES (?,?,?,?)") 
+0

我得到了一個服務器錯誤,當我使用該行代碼隊友 –

+0

,你可以檢查你的服務器日誌錯誤? – Inurosen

相關問題