在这里,我有在表单提交到同一页面后设置cookie的情况.....
这是代码:
<?php
require_once 'config.php';
$dbHandle = DBHandler::getInstance();
@session_start();
if($_POST['division'])
{
$fromDiv =$_POST['division'];
$divId =explode(',',$fromDiv);
echo $divId[0].'~';
echo $_COOKIE['preDiv'].'dfg'.'<br/>';
setcookie("preDiv",$divId[0],time() + (10 * 365 * 24 * 60 * 60));
$_SESSION['division'] = $divId[0];
}
$sql=$dbHandle->execQuery("SELECT * FROM master_division");
$division_str = '<option value="">--select--</option>';
while($fetch = $dbHandle->fetchObjectQuery($sql))
{
$division = $fetch->division_id.','.$fetch->name;
$division_str .= '<option value="'.$division.'">'.$fetch->name.'</option>';
}
echo $_COOKIE['preDiv'].'dfg'.'<br/>';
echo $_SESSION['division'];
?>
<!DOCTYPE html>
<html>
<body class="login" style="overflow: hidden;">
<div class="login-box" style="position: absolute;z-index: 999;padding: 10px;width: 40%;min-height: 200px;margin-left:-20%;">
<section class="portlet login-box-top" style="height:100%;">
<header>
<h2 class="ac">CHOOSE DIVISION To MEDISMO CRM LOGIN</h2>
</header>
<section style="height:76%;">
<div id="popup_box" > <!-- OUR PopupBox DIV-->
<div id="group_comp" style="margin-top:15%;margin-left:20%;">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" style="border:none;">
<label><b>Choose Division:</b></label>
<select id="division" name="division"><?php echo $division_str;?></select>
<input type="submit" id="ok" value="OK" />
</form>
</div>
</div>
</section>
</section>
</div>
</body>
</html>
任何人都建议我其中有什么问题...