求html登陆界面详细代码 要可以登陆,用数据库保存
3个回答
展开全部
上面给你的是asp的,这边给你个php的,你看下,不懂再问我
<?php
include("config.php");
session_start();
/*--------------------删除cookies记录,让cookies过期-----------------------------------*/
if($_GET["del"]=="cookies")
{
setcookie("usercookies", "", time()-3600);
setcookie("pwdcookies", "", time()-3600);
echo "<SCRIPT type=text/javascript>
var n = 5;
var timer = setInterval(function() {
n--;
document.getElementById('second').innerHTML = n;
if (n == 0) {
clearInterval(timer);
window.location = 'login.php';
}
}, 1000);
</SCRIPT>删除成功<br><B class='chengse STYLE1' id=second>5</B>秒后回到首页";
exit();
}
/*------------------------如果判断已经有cookies存在,则进行自动登录操作----------------------------------*/
if($_COOKIE["usercookies"]!="" and $_COOKIE["pwdcookies"]!="")
{
$username=$_POST["username"];
$userpassword=$_POST["userpassword"];
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
$rs=mysql_fetch_array($sql);
echo"自动跳转成功";
//exit();
}
/*----------------------------点击登录按钮后的动作act=login----------------------------------*/
if($_GET["act"]=="login")
{
/*------------------判断获取的验证码是否一致-------------------------*/
/*if(strtoupper($_SESSION["vcode"])!=strtoupper($_POST["Code"]))
{
echo("<script type='text/javascript'> alert('对不起,验证码错误!');location.href='javascript:onclick=history.go(-1)';</script>");
exit();
}*/
/*------------------------点击登录按钮后如果判断已经有cookies存在,则进行自动登录操作----------------------------------*/
if($_COOKIE["usercookies"]!="" and $_COOKIE["pwdcookies"]!="")
{
$username=$_POST["username"];
$userpassword=$_POST["userpassword"];
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
$rs=mysql_fetch_array($sql);
if($_POST["username"]==$rs["username"] and $_POST["userpassword"]==$rs["userpassword"])
{
echo"<script type='text/javascript'> alert('存在cookies登录跳转成功!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
else
{
echo"<script type='text/javascript'> alert('存在cookies登录跳转失败!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
exit();
}
/*-------------------点击登录后判断cookies不存在则进行登录比较用户名密码------------------------------*/
$username=$_POST["username"];
$userpassword=md5($_POST["userpassword"]);
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
if($rs=mysql_fetch_array($sql))
{
/*---------------------用户名密码判断正确,写入cookies动作,同时进行跳转------------------------------------*/
setcookie("usercookies", $_POST["username"], time()+3600*48);
setcookie("pwdcookies", md5($_POST["userpassword"]), time()+3600*24);
header('Location: http://www.baidu.com/');
exit();
}
else
{
/*-------------------判断用户名密码错误,弹出错误提示---------------------------*/
echo "<script type='text/javascript'> alert('用户名或密码错误,请重新输入!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
}
/*
$user_IP = $_SERVER["REMOTE_ADDR"];//获取访问者IP
$file_name=date('Y-m-d').'.txt';//以当前的日期建立txt文件
$file=fopen($file_name,"a+");//如果存在该文件就打开,如果不存在就创建
fwrite($file,$user_IP.'--'.date('Y-m-d H:i:s')."\r\n");//将访问者IP及当前时刻写到文件最后,\r\n在文档最后换行
fclose($file);//关闭文件
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>COOKIES判断是否自动登录</title>
</head>
<body>
<form action="?act=login" method="post">
<input name="username" type="text" id="username" value="<?php if($_COOKIE["usercookies"]!=""){echo $_COOKIE["usercookies"];}?>" />
<input name="userpassword" type="password" id="userpassword" value="<?php if($_COOKIE["pwdcookies"]!=""){echo $_COOKIE["pwdcookies"];}?>"/>
<!--<img src="yanzhengma_class.php" title="看不清楚?请点击刷新验证码" onClick="this.src='yanzhengma_class.php?t='+(new Date().getTime());" height="20px;"><input name="Code" type="text" id="Code" value="" />-->
<input name="" type="submit" />
</form>
<a href="?del=cookies">删除cookies</a>
</body>
</html>
<?php
include("config.php");
session_start();
/*--------------------删除cookies记录,让cookies过期-----------------------------------*/
if($_GET["del"]=="cookies")
{
setcookie("usercookies", "", time()-3600);
setcookie("pwdcookies", "", time()-3600);
echo "<SCRIPT type=text/javascript>
var n = 5;
var timer = setInterval(function() {
n--;
document.getElementById('second').innerHTML = n;
if (n == 0) {
clearInterval(timer);
window.location = 'login.php';
}
}, 1000);
</SCRIPT>删除成功<br><B class='chengse STYLE1' id=second>5</B>秒后回到首页";
exit();
}
/*------------------------如果判断已经有cookies存在,则进行自动登录操作----------------------------------*/
if($_COOKIE["usercookies"]!="" and $_COOKIE["pwdcookies"]!="")
{
$username=$_POST["username"];
$userpassword=$_POST["userpassword"];
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
$rs=mysql_fetch_array($sql);
echo"自动跳转成功";
//exit();
}
/*----------------------------点击登录按钮后的动作act=login----------------------------------*/
if($_GET["act"]=="login")
{
/*------------------判断获取的验证码是否一致-------------------------*/
/*if(strtoupper($_SESSION["vcode"])!=strtoupper($_POST["Code"]))
{
echo("<script type='text/javascript'> alert('对不起,验证码错误!');location.href='javascript:onclick=history.go(-1)';</script>");
exit();
}*/
/*------------------------点击登录按钮后如果判断已经有cookies存在,则进行自动登录操作----------------------------------*/
if($_COOKIE["usercookies"]!="" and $_COOKIE["pwdcookies"]!="")
{
$username=$_POST["username"];
$userpassword=$_POST["userpassword"];
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
$rs=mysql_fetch_array($sql);
if($_POST["username"]==$rs["username"] and $_POST["userpassword"]==$rs["userpassword"])
{
echo"<script type='text/javascript'> alert('存在cookies登录跳转成功!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
else
{
echo"<script type='text/javascript'> alert('存在cookies登录跳转失败!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
exit();
}
/*-------------------点击登录后判断cookies不存在则进行登录比较用户名密码------------------------------*/
$username=$_POST["username"];
$userpassword=md5($_POST["userpassword"]);
$sql=mysql_query("select * from user where username='$username' and userpassword='$userpassword'");
if($rs=mysql_fetch_array($sql))
{
/*---------------------用户名密码判断正确,写入cookies动作,同时进行跳转------------------------------------*/
setcookie("usercookies", $_POST["username"], time()+3600*48);
setcookie("pwdcookies", md5($_POST["userpassword"]), time()+3600*24);
header('Location: http://www.baidu.com/');
exit();
}
else
{
/*-------------------判断用户名密码错误,弹出错误提示---------------------------*/
echo "<script type='text/javascript'> alert('用户名或密码错误,请重新输入!');location.href='javascript:onclick=history.go(-1)';</script>";
exit();
}
}
/*
$user_IP = $_SERVER["REMOTE_ADDR"];//获取访问者IP
$file_name=date('Y-m-d').'.txt';//以当前的日期建立txt文件
$file=fopen($file_name,"a+");//如果存在该文件就打开,如果不存在就创建
fwrite($file,$user_IP.'--'.date('Y-m-d H:i:s')."\r\n");//将访问者IP及当前时刻写到文件最后,\r\n在文档最后换行
fclose($file);//关闭文件
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>COOKIES判断是否自动登录</title>
</head>
<body>
<form action="?act=login" method="post">
<input name="username" type="text" id="username" value="<?php if($_COOKIE["usercookies"]!=""){echo $_COOKIE["usercookies"];}?>" />
<input name="userpassword" type="password" id="userpassword" value="<?php if($_COOKIE["pwdcookies"]!=""){echo $_COOKIE["pwdcookies"];}?>"/>
<!--<img src="yanzhengma_class.php" title="看不清楚?请点击刷新验证码" onClick="this.src='yanzhengma_class.php?t='+(new Date().getTime());" height="20px;"><input name="Code" type="text" id="Code" value="" />-->
<input name="" type="submit" />
</form>
<a href="?del=cookies">删除cookies</a>
</body>
</html>
展开全部
这是我曾经写过的一个登录页面的详细代码,供你参考,asp的代码,不知道你看得懂不?
文件名是:deafaule.asp
<% @ Language=VBScript %>
<!--#include file="inc/jf.asp"-->
<html>
<head>
<title>欢迎使用
<%
Response.Write (JFrs("Company_Name") & " —— " & JFrs("Software_Name"))
Response.Cookies("Visiter")("Identification") = "ChunLeiSky" '设置cookies的标识,在后面检测浏览器是否支持cookies
Response.Cookies("Visiter").Expires = dateadd("n",10,now()) '设置cookies的有效期为10分钟
Dim an
Randomize
an= int((99999-11111+1) * RND +11111)
session("FrontPage_Yzm")=an
%>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<link rel="stylesheet" type="text/css" href="main.css">
<script language=VBScript src=load.js></script>
<script language="JavaScript">
function FrontPage_valid() {
if (document.FrontPage_Form.loginName.value == "") {
alert("请先输入 [用户名] !\n如果没有帐号请先 注册!");
document.FrontPage_Form.loginName.focus();
return false;
}
else if (document.FrontPage_Form.loginName.value.length < 2) {
alert("在 [用户名] 中,请至少输入 2 个字符!");
document.FrontPage_Form.loginName.focus();
return false;
}
else if (document.FrontPage_Form.loginPassword.value == "") {
alert("请输入[密码]!");
document.FrontPage_Form.loginPassword.focus();
return false;
}
else if (document.FrontPage_Form.loginPassword.value.length < 5) {
alert("在 [密码] 中,请至少输入 5 个字符!");
document.FrontPage_Form.loginPassword.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value == "") {
alert("请输入[验证码]!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value.length != 5) {
alert("在 [验证码] 中,请输入 5 位数字!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value.length == 5) {
var i=0,ch;
for (i=0;i<5;i++) {
ch=document.FrontPage_Form.FrontPage_Yzm.value.charAt(i);
if (ch<"0" || ch>"9") {
alert("在 [验证码] 中,必须输入 5 位数字!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
break;
}
}
}
else {
return true;
}
}
function setfocus() {
document.FrontPage_Form.loginPassword.focus();
return;
}
</script>
</head>
<script language="JavaScript">
if (screen.width == 1440) {
document.write("<body background='images/bg750.jpg' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />");
}
else if (screen.width == 1280) {
document.write("<body background='images/bg660.jpg' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br /><br />");
}
else {
document.write("<body BGcolor='#5A7EDC' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br />");
}
</script>
<div align="center">
<form method="post" action="login.asp" name="FrontPage_Form" onSubmit="JavaScript:return FrontPage_valid();">
<table border="0" cellpadding="0" cellspacing="0" width="548" height="350" id="table11" background="images/log.jpg">
<tr height="50"><th colspan="4" class="Fir">
<% Response.Write (JFrs("Company_Name") & " —— " & JFrs("Software_Name")) %>
</th></tr>
<tr height="36"><th colspan="4" class="warning">
<%
Dim ErrCode
ErrCode = request.QueryString("ErrCode")
If ErrCode = "-1" Then
Response.Write "<li> 您已成功修改账号信息,请等待管理员审核!"
ElseIf ErrCode = "0" Then
Response.Write "<li> 您的帐号已成功注册,请等待管理员审核!"
End If
If ErrCode = "7" Then
Response.Write "<li> [用户名] 不能为空,且至少2个汉字,最多10个汉字"
End If
If ErrCode = "8" Then
Response.Write "<li> [密码] 不能为空,且至少5个字符,最多20个字符"
End If
If ErrCode = "9" Then
Response.Write "<li> [验证码] 错误"
End If
If ErrCode = "10" Then
Response.Write "<li> [用户名] 未注册 或 [密码] 错误"
End If
If ErrCode = "20" Then
Response.Write "<li> 您的账号未通过审核,详情请咨询管理员"
End If
ErrCode = ""
%>
</th></tr>
<tr height="37"><th colspan="4" align="left"></th></tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">用户名:</td>
<td width="224"> <input type="text" name="loginName" style="width:160px;height:20px" maxlength="10" title="请输入用户名,至少2个汉字,最多10个汉字" value="<% =request.Cookies("Visiter")("VisitName") %>" onFocus="JavaScript:this.select();" onMouseOver="JavaScript:this.focus();" onClick="Javascript:this.value=''"></td>
<td width="22"></td>
</tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">密 码:</td>
<td width="224"> <input type="password" name="loginPassword" style="width:160px;height:20px" maxlength="20" title="请输入密码,至少5个字符"></td>
<td width="22"></td>
</tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">验证码:</td>
<td width="224"> <input name="FrontPage_Yzm" style="width:100px;height:20px" maxlength="5" title="请输入5位的验证码">
<% Response.Write (" " & an) %>
</td>
<td width="22"></td>
</tr>
<tr height="54">
<td width="202"></td>
<th colspan="2" valign="middle">
<input type="image" src="images/login.jpg">
<a href="JavaScript:document.FrontPage_Form.reset();"><img border="0" src="images/reset.jpg"></a>
</th>
<td width="22"></td>
</tr>
<tr height="34">
<td width="202"></td>
<th colspan="2">如果您还没有帐号,请点此 <a href="reg.asp?ErrCode=0">注册</a></th>
<td width="22"></td>
</tr>
<tr height="25" class="Sec">
<td width="202" align="center"><% Response.Write (JFrs("Company") & "® 版权所有 ") %>
</td>
<th colspan="3">Copyright© 2012 All Rights Reserved</th>
</tr>
</table>
</form>
</div>
<script language="JavaScript">
if (screen.width == 1440) {
document.write("<br /><br /><br /><br /><br /><br /><br /><br /><br />");
}
else if (screen.width == 1280){
document.write("<br /><br /><br /><br />");
}
else {
document.write("<br /><br /><br /><br /><br />");
}
</script>
<center>建议使用 IE8.0或更高版本的浏览器,推荐分辨率1440×900 或更高<br />
<%
Response.Write (JFrs("Company") & "® " & JFrs("Software_Name") & " V1.0")
JFrs.Close
set JFrs = Nothing
CloseDataBase
%>
</center>
</body>
</html>
文件名是:deafaule.asp
<% @ Language=VBScript %>
<!--#include file="inc/jf.asp"-->
<html>
<head>
<title>欢迎使用
<%
Response.Write (JFrs("Company_Name") & " —— " & JFrs("Software_Name"))
Response.Cookies("Visiter")("Identification") = "ChunLeiSky" '设置cookies的标识,在后面检测浏览器是否支持cookies
Response.Cookies("Visiter").Expires = dateadd("n",10,now()) '设置cookies的有效期为10分钟
Dim an
Randomize
an= int((99999-11111+1) * RND +11111)
session("FrontPage_Yzm")=an
%>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<link rel="stylesheet" type="text/css" href="main.css">
<script language=VBScript src=load.js></script>
<script language="JavaScript">
function FrontPage_valid() {
if (document.FrontPage_Form.loginName.value == "") {
alert("请先输入 [用户名] !\n如果没有帐号请先 注册!");
document.FrontPage_Form.loginName.focus();
return false;
}
else if (document.FrontPage_Form.loginName.value.length < 2) {
alert("在 [用户名] 中,请至少输入 2 个字符!");
document.FrontPage_Form.loginName.focus();
return false;
}
else if (document.FrontPage_Form.loginPassword.value == "") {
alert("请输入[密码]!");
document.FrontPage_Form.loginPassword.focus();
return false;
}
else if (document.FrontPage_Form.loginPassword.value.length < 5) {
alert("在 [密码] 中,请至少输入 5 个字符!");
document.FrontPage_Form.loginPassword.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value == "") {
alert("请输入[验证码]!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value.length != 5) {
alert("在 [验证码] 中,请输入 5 位数字!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
}
else if (document.FrontPage_Form.FrontPage_Yzm.value.length == 5) {
var i=0,ch;
for (i=0;i<5;i++) {
ch=document.FrontPage_Form.FrontPage_Yzm.value.charAt(i);
if (ch<"0" || ch>"9") {
alert("在 [验证码] 中,必须输入 5 位数字!");
document.FrontPage_Form.FrontPage_Yzm.focus();
return false;
break;
}
}
}
else {
return true;
}
}
function setfocus() {
document.FrontPage_Form.loginPassword.focus();
return;
}
</script>
</head>
<script language="JavaScript">
if (screen.width == 1440) {
document.write("<body background='images/bg750.jpg' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />");
}
else if (screen.width == 1280) {
document.write("<body background='images/bg660.jpg' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br /><br />");
}
else {
document.write("<body BGcolor='#5A7EDC' onload='JavaScript:setfocus();'><br /><br /><br /><br /><br /><br /><br />");
}
</script>
<div align="center">
<form method="post" action="login.asp" name="FrontPage_Form" onSubmit="JavaScript:return FrontPage_valid();">
<table border="0" cellpadding="0" cellspacing="0" width="548" height="350" id="table11" background="images/log.jpg">
<tr height="50"><th colspan="4" class="Fir">
<% Response.Write (JFrs("Company_Name") & " —— " & JFrs("Software_Name")) %>
</th></tr>
<tr height="36"><th colspan="4" class="warning">
<%
Dim ErrCode
ErrCode = request.QueryString("ErrCode")
If ErrCode = "-1" Then
Response.Write "<li> 您已成功修改账号信息,请等待管理员审核!"
ElseIf ErrCode = "0" Then
Response.Write "<li> 您的帐号已成功注册,请等待管理员审核!"
End If
If ErrCode = "7" Then
Response.Write "<li> [用户名] 不能为空,且至少2个汉字,最多10个汉字"
End If
If ErrCode = "8" Then
Response.Write "<li> [密码] 不能为空,且至少5个字符,最多20个字符"
End If
If ErrCode = "9" Then
Response.Write "<li> [验证码] 错误"
End If
If ErrCode = "10" Then
Response.Write "<li> [用户名] 未注册 或 [密码] 错误"
End If
If ErrCode = "20" Then
Response.Write "<li> 您的账号未通过审核,详情请咨询管理员"
End If
ErrCode = ""
%>
</th></tr>
<tr height="37"><th colspan="4" align="left"></th></tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">用户名:</td>
<td width="224"> <input type="text" name="loginName" style="width:160px;height:20px" maxlength="10" title="请输入用户名,至少2个汉字,最多10个汉字" value="<% =request.Cookies("Visiter")("VisitName") %>" onFocus="JavaScript:this.select();" onMouseOver="JavaScript:this.focus();" onClick="Javascript:this.value=''"></td>
<td width="22"></td>
</tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">密 码:</td>
<td width="224"> <input type="password" name="loginPassword" style="width:160px;height:20px" maxlength="20" title="请输入密码,至少5个字符"></td>
<td width="22"></td>
</tr>
<tr height="38">
<td width="202"></td>
<td width="100" align="right">验证码:</td>
<td width="224"> <input name="FrontPage_Yzm" style="width:100px;height:20px" maxlength="5" title="请输入5位的验证码">
<% Response.Write (" " & an) %>
</td>
<td width="22"></td>
</tr>
<tr height="54">
<td width="202"></td>
<th colspan="2" valign="middle">
<input type="image" src="images/login.jpg">
<a href="JavaScript:document.FrontPage_Form.reset();"><img border="0" src="images/reset.jpg"></a>
</th>
<td width="22"></td>
</tr>
<tr height="34">
<td width="202"></td>
<th colspan="2">如果您还没有帐号,请点此 <a href="reg.asp?ErrCode=0">注册</a></th>
<td width="22"></td>
</tr>
<tr height="25" class="Sec">
<td width="202" align="center"><% Response.Write (JFrs("Company") & "® 版权所有 ") %>
</td>
<th colspan="3">Copyright© 2012 All Rights Reserved</th>
</tr>
</table>
</form>
</div>
<script language="JavaScript">
if (screen.width == 1440) {
document.write("<br /><br /><br /><br /><br /><br /><br /><br /><br />");
}
else if (screen.width == 1280){
document.write("<br /><br /><br /><br />");
}
else {
document.write("<br /><br /><br /><br /><br />");
}
</script>
<center>建议使用 IE8.0或更高版本的浏览器,推荐分辨率1440×900 或更高<br />
<%
Response.Write (JFrs("Company") & "® " & JFrs("Software_Name") & " V1.0")
JFrs.Close
set JFrs = Nothing
CloseDataBase
%>
</center>
</body>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在页面上用一个submit提交用户名和密码,form跳转到后台代码上,进行用户名验证,当然,是在已经连接数据库的情况下,正确,跳转到index.html,否则,在跳转到login.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询