在使用預準備語句降低SQL注入風險之後,按鈕單擊會將頁面留爲空白。我在代碼中找不到任何錯誤。什麼導致頁面變爲空白,我如何防止它發生?準備好聲明後的空白頁面PHP
if(isset($_POST['desc_btn'])) {
$code = mysqli_real_escape_string($con, strip_tags($_POST['code_desc']));
$desc = mysqli_real_escape_string($con, strip_tags($_POST['description']));
$code_select = $con->prepare("SELECT * FROM data WHERE code=?");
$code_select->bind_param("s", $code);
$code_select->execute();
$data = $code_select->get_result();
$data_user_id = $data['user_id'];
$data_id = $data['id'];
if($user_id == $data_user_id ) {
$code_select->close();
$update = $con->prepare("UPDATE data SET description=? WHERE id=?");
$update->bind_param('s', $desc, $data_id;
$update->execute();
$update->close();
}
}
error_reporting(E_ALL);
感謝您的幫助。我願意接受任何意見。
首先,你不應該使用mysqli_real_escape_string,PHP PDO做所有轉義,它需要它本身 –
頁面應該是空白的。你在這裏沒有迴應任何東西。 – Akintunde007