演示代码如下:
一. 表单页面
Insert title hereName:
Age:
Email:
Password:
二 数据处理页面
header("Content-type: text/html; charset=GBK");
$username=$_POST['username'];
if(!isset($_POST["send"]) || $_POST["send"] !='提交'){
header("Location:Demo13.php");
exit;
}else{
$username=$_POST['username'];
// $password=$_POST["pwd"];
$password=$_COOKIE['password'];
$email=$_POST["email"];
$age=$_POST["age"];
if(strlen($password)<5){
echo "";
exit;
}else{
setcookie("username",$username,time()+7*224*60*60);
setcookie("password",$password,time()+7*224*60*60);
session_start();
$_SESSION['password']=$password;
header("Location:Demo14.php");
}
}
?>
三,处理成功,跳转从Cookie,Session中获取数据,展现
header("Content-type: text/html; charset=GBK");
session_start();
echo "重Cookie中获取的用户名:".$_COOKIE["username"];
echo "从Session中获取的密码:".$_SESSION["password"];
echo "从Cookie中获取的密码:".$_COOKIE["password"];
?>