내 코드가 작동하지 않습니다. php와 mysqli를 사용하여 로그인 웹 사이트를 구축하고 있습니다. 나는 보안을 향상시키기 위해 준비된 진술을 포함 시키지만 나는 잘못하고 있다고 생각한다. 도와주세요.PHP mysqli 준비 문을 사용하여 질문을 보낼 수 없습니다.
정보를 데이터베이스로 보낼 수 없습니다.
"prepared failed!" 나타나다. 문제가 무엇입니까 ??
<?php
if(isset($_POST['signup-name'], $_POST['signup-password-1'], $_POST['signup-password-2'], $_POST['signup-email-1'], $_POST['signup-email-2'], $_POST['signup-country'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'])){
if(!empty($_POST['signup-name']) and !empty($_POST['signup-password-1']) and !empty($_POST['signup-password-2']) and !empty($_POST['signup-email-1']) and !empty($_POST['signup-email-2']) and !empty($_POST['signup-country']) and !empty($_POST['recaptcha_challenge_field']) and !empty($_POST['recaptcha_response_field'])){
echo"ok";
$username = $_POST['signup-name'];
$password1 = $_POST['signup-password-1'];
$password2 = $_POST['signup-password-2'];
$email1 = $_POST['signup-email-1'];
$email2 = $_POST['signup-email-2'];
$country = $_POST['signup-country'];
//$recaptcha_challenge_field = $_POST['recaptcha_challenge_field'];
//$recaptcha_response_field = $_POST['recaptcha_response_field'];
if (filter_var($email1, FILTER_VALIDATE_EMAIL) && ($email1==$email2) && ($password1==$password2)) {
include 'db_info.php';
$mysqli = new mysqli("localhost", $db_uusseerrss, $db_ppwwdd, "user_db");
if (mysqli_connect_errno()) {
echo "no ok";
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "INSERT INTO user_info (`username`, `email`, `password`, `country`) VALUES(?, ?, ?, ?)";
if ($stmt = $mysqli->prepare($query)) {
$stmt->bind_param('ssss', $username, $email1, $hashed_password, $country);
$stmt->execute();
$stmt->close();
//mysqli_close($link);
}else{
die('prepare() failed: ' . htmlspecialchars($stmt->error));
}
}else{
echo "filter failed!";
}
}else{
echo "value is not set";
}
}
}
?>
단어가 MySQL에 의해 예약 될 때만 Backticks가 필요합니다. 그 단어들 중 어느 것도 예약되어 있지 않으므로 backticks로 그냥 탈출 할 이유가 없습니다. – Ohgodwhy
예. 맞습니다. 역 따옴표는 예약 된 키워드 또는 공백이있는 열 이름이 필요한 경우에만 필요합니다. –
여전히 작동하지 않습니다. < – John