<?php
error_reporting
(0);
session_start();
?>
<!doctype html>
<html>
<head>
<meta http-equiv=
"content-type"
content=
"text/html; charset=gb2312"
/>
<title>网页登录中实现记住用户名和密码的功能(完成自动登录)</title>
</head>
<body>
<?php
$uid
=
$_cookie
['uid'];
$pwd
=
$_cookie
['uid'];
if
(
$uid
!='' &&
$pwd
!='' )
{
$_session
['uid'] ='abc';
}
if
(
$_session
['uid'] )
{
echo
'会员中心,发表文章,到http:
}
else
{
?>
<form id=
"form1"
name=
"form1"
method=
"post"
action=
""
>
<p>
<label
for
=
"uid"
></label>
<input type=
"text"
name=
"uid"
id=
"uid"
/>
</p>
<p>
<label
for
=
"pwd"
></label>
<input type=
"text"
name=
"pwd"
id=
"pwd"
/>
</p>
<p>
<input type=
"checkbox"
name=
"checkbox"
id=
"checkbox"
value=
"7"
/>
<label
for
=
"checkbox"
></label>
一周内不用登录
</p>
<p>
<input type=
"submit"
name=
"button"
id=
"button"
value=
"登录"
/>
</p>
<p> </p>
</form>
<?php
}
?>
</body>
</html>
<?php
if
(
$_post
)
{
$info
=
$_post
;
if
(
$info
['uid'] !='' &&
$info
['pwd'] !='')
{
if
(
intval
(
$info
['checkbox']) )
{
setcookie('uid',
$info
['uid'],time()+3600*24*7,'/','192.168.0.118');
setcookie('pwd',
$info
['pwd'],time()+3600*24*7,'/','192.168.0.118');
}
$_session
['uid'] ==
$info
['uid'];
}
}
?>