gpt4 book ai didi

php - 输入正确的 Google Recaptcha 挑战和激活码后无法重定向到所需页面

转载 作者:行者123 更新时间:2023-11-30 00:14:40 24 4
gpt4 key购买 nike

即使输入正确的验证码挑战和激活码后,我也无法重定向到我想要的页面。我怀疑我的 php 激活脚本有什么问题。任何人都可以检查我的脚本中的错误是什么?

这是我的脚本:

<?php
require_once('recaptchalib.php');
$privatekey = "6LfTwvMSAAAAABt03yGb0_12rgLNrCDuoibU4gbh";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
$username = $_POST['username'];
$activation_code = $_POST['activation_code'];
$db_host = "server";
$db_name = "table";
$db_use = "user";
$db_pass = "pass";
$link = mysqli_connect($db_host, $db_use, $db_pass);
mysqli_select_db($link, $db_name);
$command = "UPDATE email_activation SET check_activation='$activation_code' WHERE username='$username' and activation='$activation_code'";
$result = mysqli_query($command);
if ($result) {
$query = "SELECT * FROM email_activation where username LIKE '%$username%' LIMIT 0 , 1 ";
$result = mysqli_query($query) OR die(mysqli_error());
while($row = mysqli_fetch_array($result))
{
$username = $row['username'];
$password = $row['password'];
$email = $row['email'];
$postcode = $row['postcode'];
$query = "INSERT INTO member (username, password, email, postcode) VALUES ('$username','$password','$email','$postcode')";
$result = mysqli_query($link, $query) OR die(mysqli_error());
if ($result) {
echo "Congratulations. Your membership has been activated redirecting...";
$_SESSION['user_logged'] = '1';
header("location:index.html");
}else{
echo ("Congratulations. Your membership has been activated but it's can't saved in database.");
header("location:index.html");
}
}
}else{
echo ("You've entered an invalid username / activation code – please retry");
header("location:activation-form.php");
}
}
?>

最佳答案

你不能使用 header('location: Something.html');回显数据后。

在将任何内容发送到浏览器之前,必须调用 header 。

echo ("Congratulations. Your membership has been activated but it's can't saved in database.");
header("location:index.html");

我建议将错误传递到下一页...

header("location: index.html?err=dberr");

关于php - 输入正确的 Google Recaptcha 挑战和激活码后无法重定向到所需页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23760804/

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