好吧,我创建了一个年龄门,从表单中运行年龄计算,但是一旦开始使用重定向,事情就会变得疯狂。首先,当我在本地主机上加载verify.php页面时,首先在填写年龄信息后点击提交按钮时重新加载页面。然后我再做一次,重定向工作?把它带到外面的网站时它很有用,但是当我真正得到年龄验证时,它会把我带到index.php但是然后index.php再次将我重定向到verify.php页面,直到浏览器开始抱怨重定向cookie问题。我不明白为什么它至少暂时没有创建会议。
所以我在verify.php表单页面中有php,所以它在同一页面上
VERIFY.PHP
<?php
session_start();
if(isset($_SESSION['verifyok']))
{
header("location: index.php");
exit(0);
}
if(isset($_SESSION['verifyfail']))
{
header("location: http://www.centurycouncil.org/");
exit(0);
}
if($_POST)
{
$remember = $_REQUEST ['remember'];
$day = $_POST ['day'];
$month = $_POST ['month'];
$year = $_POST ['year'];
$country = $_POST ['country'];
$birthday = mktime(0,0,0,$month,$day,$year);
$difference = time() - $birthday;
$age = floor($difference / 31556926);
if($age >= 21)
{
$_SESSION ['verifyok'] = 1;
header ("location: index.php");
exit(0);
}
else
{
$_SESSION ['verifyfail'] = 0;
header("loaction: http://www.centurycouncil.org/");
exit(0);
}
if($remember == 'save')
{
setcookie("verifyok", 1,mktime(0,0,0,01,01,date("Y")+30));
$_SESSION ['verified'] = 1;
header("location: index.php");
exit(0);
}
}
?>
的index.php
<?php
session_start();
if(!isset($_SESSION['verifyok'])){
header("location: verify.php");
exit;
}
?>
提前感谢您的支持!