login.html
<html>
<head>
<title>注册页面</title>
<meta charset="utf-8">
</head>
<body>
<form action="log.php?action=1" method="post">
请输入姓名 <input type = "text" name = "username" > <br>
请输入密码 <input type="password" name="password" ><br>
您的性别是:<input type="radio" name="sex" value="1">男
<input type="radio" name="sex" value="2">女<br>
您的邮箱是:<input type="emile" name="emile"><br>
您的心情是:<select name="mood">
<option value="A" >开心</option>
<option value="C" >忧郁</option>
<option value="B" >迷茫</option>
</select><br>
您的爱好是:<br>
<input type="checkbox" name="fav[]" value="篮球">篮球
<input type="checkbox" name="fav[]" value="足球">足球
<input type="checkbox" name="fav[]" value="乒乓球">兵乓球
<input type="checkbox" name="fav[]" value="其他" checked>等等<br>
您对这个表单的意见:<br>
<textarea name="desp" row="60" col="50">感谢您的意见。。。</textarea><br>
<button type="reset" name="reload" >刷新</button>
<input type = "submit" name = "submit1" value="确定"><br>
</form>
</body>
</html>
log.php
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_REQUEST['action'])&&$_REQUEST['action']==1){
$username=$_POST['username'];
$password=$_POST['password'];
$sex=$_POST['sex'];
$emile=$_POST['emile'];
$mood=$_POST['mood'];
$fav=$_POST["fav[]"];
// echo "用户名是{$username},密码是{$password}";
setcookie("username",$username,time()+10*60);
setcookie("password",md5($password),time()+10*60);
setcookie("sex",$sex,time()+10*60);
setcookie("emile",$emile,time()+10*60);
setcookie("mood",$mood,time()+10*60);
setcookie("fav",$fav,time()+10*60);
setcookie("login",1,time()+10*60);}
elseif (isset($_REQUEST['action'])&&$_REQUEST['action']==2) {
setcookie("username",'',time()-10*60);
setcookie("login",0,time()-10*60);
}
header("Location:text.php");
?>
</body>
</html>
不知道为什么,fav[]的值无法存入cookieQAQ
小白求助~+。+
我是新手_请多指教