我一直得到不能通過參考傳遞參數2,雖然名稱在形式,變量類型是好的。 我看過其他人的病例,他們似乎很合理,但我無法在這裏找到我的錯誤。connot通過參數傳遞參數
$sid = $_POST['staff_id'];
$sname = $_POST['staff_name'];
$sgender = $_POST['gender'];
$sdob = $_POST['staff_dob'];
$sbranch = $_POST['branch'];
$stell = $_POST['tel_no'];
$position = $_POST['position'];
$salary =$_POST['salary'];
$login = $_POST['staff_login'];
$password = $_POST['staff_password'];
}
else{
$stmt = $mysqli->prepare("INSERT INTO
staff (staff_id, staff_name, gender, staff_dob, branch, tell_no, position, salary, staff_login, staff_password) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssiiss', '$sid', '$sname', '$sgender', '$sdob', '$sbranch', '$stell', '$position', '$salary', '$login', '$password');
這裏是我的HTML表單:
<form method="post" action="">
<input type="text" name="staff_id" placeholder="your given ID">
<input type="text" name="staff_name" placeholder="Full Name"/>
<label class="formlabel">Your gender:</label>
<input type="text" name="gender" placeholder="male/female">
<label class="formlabel"><b>Date of Birth:</b></label>
<input type="date" name="staff_dob">
<input type="text" name="branch" placeholder="Your branch ID">
<input type="tel" name="tel_no" placeholder="your telephone number">
<label class="formlabel"><b>Your position</b></label>
<select name="position">
<option value="1"> Asisstant</option>
<option value="2"> Supervisor</option>
<option value="3"> Manager</option>
</select>
<input type="number" name="salary" placeholder="your salary ammount">
<input type="text" name="staff_login" placeholder="Make your new login">
<input type="password" name="staff_password" placeholder="Enter your new password">
<button type="submit" name="btn-register" value="submit">Register</button>
</form>
還有''sid''這是錯誤的,而不是使用'$ sid'而不是引號 –
sqli之前的其他功能是什麼?你需要這些後變量,它看起來像... – clearshot66
當然,謝謝你,你是對的 –