我是新来的PHP,有没有什么办法可以在激活成功后使用PHP身份验证(auth)或会话直接记录用户?登录使用PHP身份验证或激活后的会话
这里是我的激活脚本:
<?php
require_once('recaptchalib.php');
$privatekey = "your_private_key";
$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 = "localhost";
$db_name = "databasename";
$db_use = "root";
$db_pass = "password";
$link = mysqli_connect($db_host, $db_use, $db_pass);
mysqli_select_db($db_name, $link);
$command = "UPDATE email_activation SET check_activation='$activation_code' WHERE username='$username' and activation='$activation_code'";
$result = mysqli_query($command);
if ($result) {
echo "Congratulations. Your membership has been activated …";
}else{
echo ("You've entered an invalid username/activation code – please retry");
}
}
?>
你在调用'session_start'吗? – T0xicCode
如何使用会话启动? – Vinson