看板Programming
标 题php与cookie传递问题
发信站KKCITY (Fri Sep 29 09:25:44 2006)
转信站ptt!ctu-reader!ctu-peer!news.nctu!nctumenews!news.ind.ntou!news.ntu!bb
大家好
我设计一个登入网页index.php和另一个验证的a001.php网页
当我第一次进入index.php网业输入与蜜码登入成功後
当我第二次在开index.php网页时因该是显示你登入罗
但它好像无法c抓到a001.php内设定的cookie值,但在用户端
电脑有个cokkie档案,不知问题出再哪,谢谢
附原始码
index.php:
<?php
$a1=$_cookie["username"];
$a2=$_cookie["userpaswd"];
if ($a1=="jeremy" and $a2=="my3035138")
{ echo "你已经登入系统罗";
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>php程式</title>
<style type="text/css">
<!--
style1 {
font-family: "标楷体";
font-size: 12pt;
}
style2 {
font-family: "标楷体";
font-size: 36px;
color: #CC3300;
}
-->
</style>
</head>
<body>
<p align="center" class="style2">PHP程式设计测试</p>
<form name="form1" method="post" action="a001.php">
<p align="center"><span class="style1">帐号:</span>
<input name="user" type="text" id="user" maxlength="15">
</p>
<p align="center"><span class="style1">密码:</span>
<input name="passwd" type="password" id="passwd" maxlength="10">
</p>
<p align="center">
<input type="submit" name="Submit" value="送出">
<input type="reset" name="Submit2" value="清除输入">
</p>
</form>
<p align="center"> </p>
</body>
</html>
a001.php部份
<?php
$name=$_POST["user"];
$passwd=$_POST["passwd"];
setcookie("username",$name,time()+120);
setcookie("userpasswd",$passwd,time()+120);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!-- Creation Date: <?=Date("d/m/Y")?> -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="Generator" content="Dev-PHP 1.9.4">
<title>Document Title</title>
</head>
<body>
<?php
if ( $name !="jeremy" or
$passwd !="my3035138" )
{ echo "帐号密码输入错误";
exit; }
?>
恭喜您,登入成功!<br>
您可以执行以下功能:<br>
....<br>
....<br
</body>
</html>
--
☆★☆★☆★☆★☆★☆★☆★☆★
□ ◎武藤新二◎ □
★☆★☆★☆★☆★☆★☆★☆★☆
--
┌─────◆KKCITY◆─────┐ ◢
◤ 听 KKBOX,
动态歌词紧紧跟着你
│ bbs.kkcity.com.tw │ \^_^ / ★ http://www.kkbox.com.tw ★
└──《From:61.218.97.139
》──┘ ◤ 唱片公司授权,音乐尽情下载
--