ı正在使用一个代码块,ı已经在不同的插入数据过程中使用,但ı不知道为什么,它不工作。它向我发送 contact.php?in=error。
<?php
if(@$_POST['submit']){
$gizlicap = $_POST['hcaptcha'];
$code = $_POST['captcha'];
if($code == $gizlicap){
$name = htmlspecialchars($_POST['ad'], ENT_QUOTES, 'utf-8');
$email = htmlspecialchars($_POST['eposta'], ENT_QUOTES, 'utf-8');
$yazi = htmlspecialchars($_POST['text'], ENT_QUOTES, 'utf-8');
$snd = $db->prepare("INSERT INTO `contactform` (`message_id`, `message_ad`, `message_email`, `message`) VALUES (NULL, :ad, :email, :yazi) ");
$snd->bindValue(":ad", $name, PDO::PARAM_STR);
$snd->bindValue(":email", $email, PDO::PARAM_STR);
$snd->bindValue(":yazi", $yazi, PDO::PARAM_STR);
if($snd->execute()) {
@header("Location: contact.php?in=success");
} else {
@header("Location: contact.php?in=error");
}
} else {
echo 'Check security code!!';
}
}
?>
你有定义$db变量吗?捉迷藏 指令来处理异常,这样你就会收到错误的信息。