用session 或cookie来实现
这是我的再现书店的登录程序,仅供参考!
<?
#########################################
# Buy Book Online #
# Version:1.0 #
# 程序版权:LsNetWork #
# 程序开发:bombshell & supsuccess #
# 官方网站:www.gotong.com #
#########################################
$thisprog = "login.php";
include ("include/functions.php");
head();
template();if(empty($_POST['action']))
{
navigation("在线借阅系统","用户登录");
login_index();
footer();
exit;
}
elseif($_POST['action'] == "login")
{
navigation("在线借阅系统","用户登录"); //显示导航条
deletecookies();
user_login();
footer;
exit;
}//用户登录检查
function user_login()
{
global $_POST,$db;
$nicker = safe_convert($_POST['nicker']);
if(!$nicker)
{
$content = "用户名没有填写.<br><br>
请返回上一页填写<br>";
$content.= "<form action='$thisprog' method='post'>
<input type=button value='返回上一页' onclick ='self.history.back();'>
</form>";
msg_box("登录出现错误",$content);
exit;
}
$sql = "select nicker,password from user_info where nicker ='$nicker'";
$db->query($sql);
$db->records();
if($nicker!=$db->get('nicker') || $_POST['password']!=$db->get('password'))
{
$content = "用户名或者密码不正确.<br><br>
请返回上一页重新登录<br>";
$content.= "<form action='$thisprog' method='post'>
<input type=button value='返回上一页' onclick ='self.history.back();'>
</form>";
msg_box("登录出现错误",$content);
exit;
}
setcookie("reg_nicker",$db->get('nicker'));
setcookie("reg_password",md5($db->get('password')));
ob_end_flush();
jump_page('index.php','成功登录','<br>状态:用户成功登录!<br><ul><li><a href="index.php">返回首页</a></li></ul>');
exit;
}
//显示登录页面login_index()
function login_index()
{
global $thisprog;
print <<<EOT
<TABLE border=0 cellPadding=0 cellSpacing=0 align=center>
<TR>
<TD bgColor=#000000>
<TABLE border=0 cellPadding=4 cellSpacing=1 >
<TR>
<TD bgColor=$titlecolor><font color=#000000><B>登录</B></FONT>
</TD>
</TR>
<TR bgColor=$trbgcolor>
<TD>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td width="4%"><img src='' width=1 height=1></td>
<td width="91%"><br>
请输入你的昵称和密码登录。如果你还没有注册请 <a href="register.php">注册</a>.
注意:你的浏览器需要打开设置,接受cookie,否则你不能成功登录。<br>
<b>
<FONT color=red>安全注意 : </FONT> </b>如果你用公共的机器, 你离开的时候请点击<font color=red>退出登录</font>.
</td>
<td width="5%"><img src='' width=0 height=0></td>
</tr>
</table>
<P>
<FORM action="$thisprog" method=post>
<BLOCKQUOTE>
<TABLE border=0 cellPadding=4>
<TR>
<TD align=right>用户名:</TD>
<TD>
<INPUT type=text name="nicker" maxLength=25 size=40 class="stedit">
<a href="sendpws.php">忘了密码?</a>
</TD>
</TR>
<TR>
<TD align=right>密 码:</TD>
<TD>
<INPUT type=password name="password" maxLength=25 size=40 class="stedit">
<input type=hidden name="action" value="login">
<INPUT type=submit name="submit" value="登 录" class="stedit">
</TD>
</TR>
</TABLE>
</BLOCKQUOTE> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width=$intabwidth>
<tr>
<td width="4%"><img src='' width=0 height=0></td>
<td width="90%">如果你忘记了密码,请点击忘了密码连接,该系统会验证你的身份后把你密码发送到你的信箱中。如果你的信箱也忘了,请联系管理员<<A href="mailto:$admin_email">$admin_email</A>>
</td>
<td width="6%"><img src='' width=0 height=0></td>
</tr>
</table> </FORM>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE><br>
</td></tr></table>
EOT;
}?>
这是我的再现书店的登录程序,仅供参考!
<?
#########################################
# Buy Book Online #
# Version:1.0 #
# 程序版权:LsNetWork #
# 程序开发:bombshell & supsuccess #
# 官方网站:www.gotong.com #
#########################################
$thisprog = "login.php";
include ("include/functions.php");
head();
template();if(empty($_POST['action']))
{
navigation("在线借阅系统","用户登录");
login_index();
footer();
exit;
}
elseif($_POST['action'] == "login")
{
navigation("在线借阅系统","用户登录"); //显示导航条
deletecookies();
user_login();
footer;
exit;
}//用户登录检查
function user_login()
{
global $_POST,$db;
$nicker = safe_convert($_POST['nicker']);
if(!$nicker)
{
$content = "用户名没有填写.<br><br>
请返回上一页填写<br>";
$content.= "<form action='$thisprog' method='post'>
<input type=button value='返回上一页' onclick ='self.history.back();'>
</form>";
msg_box("登录出现错误",$content);
exit;
}
$sql = "select nicker,password from user_info where nicker ='$nicker'";
$db->query($sql);
$db->records();
if($nicker!=$db->get('nicker') || $_POST['password']!=$db->get('password'))
{
$content = "用户名或者密码不正确.<br><br>
请返回上一页重新登录<br>";
$content.= "<form action='$thisprog' method='post'>
<input type=button value='返回上一页' onclick ='self.history.back();'>
</form>";
msg_box("登录出现错误",$content);
exit;
}
setcookie("reg_nicker",$db->get('nicker'));
setcookie("reg_password",md5($db->get('password')));
ob_end_flush();
jump_page('index.php','成功登录','<br>状态:用户成功登录!<br><ul><li><a href="index.php">返回首页</a></li></ul>');
exit;
}
//显示登录页面login_index()
function login_index()
{
global $thisprog;
print <<<EOT
<TABLE border=0 cellPadding=0 cellSpacing=0 align=center>
<TR>
<TD bgColor=#000000>
<TABLE border=0 cellPadding=4 cellSpacing=1 >
<TR>
<TD bgColor=$titlecolor><font color=#000000><B>登录</B></FONT>
</TD>
</TR>
<TR bgColor=$trbgcolor>
<TD>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
<tr>
<td width="4%"><img src='' width=1 height=1></td>
<td width="91%"><br>
请输入你的昵称和密码登录。如果你还没有注册请 <a href="register.php">注册</a>.
注意:你的浏览器需要打开设置,接受cookie,否则你不能成功登录。<br>
<b>
<FONT color=red>安全注意 : </FONT> </b>如果你用公共的机器, 你离开的时候请点击<font color=red>退出登录</font>.
</td>
<td width="5%"><img src='' width=0 height=0></td>
</tr>
</table>
<P>
<FORM action="$thisprog" method=post>
<BLOCKQUOTE>
<TABLE border=0 cellPadding=4>
<TR>
<TD align=right>用户名:</TD>
<TD>
<INPUT type=text name="nicker" maxLength=25 size=40 class="stedit">
<a href="sendpws.php">忘了密码?</a>
</TD>
</TR>
<TR>
<TD align=right>密 码:</TD>
<TD>
<INPUT type=password name="password" maxLength=25 size=40 class="stedit">
<input type=hidden name="action" value="login">
<INPUT type=submit name="submit" value="登 录" class="stedit">
</TD>
</TR>
</TABLE>
</BLOCKQUOTE> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width=$intabwidth>
<tr>
<td width="4%"><img src='' width=0 height=0></td>
<td width="90%">如果你忘记了密码,请点击忘了密码连接,该系统会验证你的身份后把你密码发送到你的信箱中。如果你的信箱也忘了,请联系管理员<<A href="mailto:$admin_email">$admin_email</A>>
</td>
<td width="6%"><img src='' width=0 height=0></td>
</tr>
</table> </FORM>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE><br>
</td></tr></table>
EOT;
}?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货