gpt4 book ai didi

javascript - php echo后显示黑屏

转载 作者:行者123 更新时间:2023-11-28 17:53:24 24 4
gpt4 key购买 nike

显示 echo 后,当您单击“确定”时,它只是转到 php 文件,该文件什么也不显示(所以我最终得到一个空白屏幕),这种情况发生了两次,我该如何修复它?

显示第二个回显后,当您单击“确定”时,它必须返回页面,以便用户可以执行 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 = "mail@hotmail.com";
$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: mail2@hotmail.com" . "\r\n";
mail($to, $subject, $body, $headers);
} else {
echo "Er ging iets mis, probeer opnieuw of contacteer de administrator op mail2@hotmail.com!";
}

} 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>

关于javascript - php echo后显示黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44972192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com