Php后显示空白屏幕回显
显示回显后,当您点击'确定',它只是去显示什么都不显示(所以我结束了一个空白屏幕)的PHP文件,这发生了两次,我该如何修复它?Php后显示空白屏幕回显
在显示第二个回显后,当您点击'ok'时,它必须返回到页面以便用户可以执行reCAPTCHA,现在它只进入不显示任何内容的php文件(所以我最终一个空白屏幕)
<?php
// grab recaptcha library
require_once "recaptchalib.php";
// your secret key
$secret = "secretkey";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
if ($response != null && $response->success) {
if(isset($_POST['submit'])) {
$to = "[email protected]";
$subject = "Voorstel ---.synology.me";
$suggest = $_POST['comment'];
$body = " NL\n Suggestie: $suggest\n";
echo "<script>alert('Je voorstel is verstuurd, wij proberen dit zo snel mogelijk te verwezelijken!');</script>";
//after previous echo is displayed, when you click 'ok', it just goes to the php file which displays nothing (so I end up with a blank screen)
$headers = "From: [email protected]" . "\r\n";
mail($to, $subject, $body, $headers);
} else {
echo "Er ging iets mis, probeer opnieuw of contacteer de administrator op [email protected]!";
}
} else {
echo "<script>alert('Vul de Captcha correct in!');</script>";
//after previous echo is displayed, when you click 'ok', it must go back to the page so the user can do the reCAPTCHA
//now it just goes to the php file which displays nothing (so I end up with a blank screen)
}
?>
而不是一个警报,如何确认重定向页面?
<script>
if(confirm('Vul de Captcha correct in!')){
window.location.href = "yourpage.php";
}
</script>
不要忘记确保你的回声格式正确。
echo "<script>
if(confirm('Vul de Captcha correct in!')){
window.location.href = 'yourpage.php';
}
</script>";
无论选择何种方式,只要用if语句就可以产生相同的效果。
<script>
if(confirm('Vul de Captcha correct in!')){
window.location.href = "yourpage.php";
}else{
window.location.href = "yourpage.php";
}
</script>
解析错误:语法错误,意外的'yourpage'(T_STRING),期待','或';'在/volume1/web/JocanasNLsuggest.php上线42 它给了我这个错误。如果我用https://google.com/替换yourpage.php,我仍然会得到相同的错误。难道我做错了什么? – Limoentaart
您必须删除nextline。将所有代码包装在一行中。 – Th3
谢谢,它现在可以工作!当我按ok,页面重新加载,但当我按下取消,它结束了PHP,我最终再次白色屏幕。我怎么能这样做,当你按下取消,它确实一样。或者有没有可能让取消按钮消失? – Limoentaart
不共享你的私钥公开 –
打开使用error_reporting,看它是否显示了一个致命的错误 – ThisGuyHasTwoThumbs
在你过去的其他语句的页面加载完成后,你给用户一个JavaScript警告,在用户点击后'确定'肯定没有发生,因为页面完成加载。 – Harrie