求html登陆界面详细代码 要可以登陆,用数据库保存

html-css07

求html登陆界面详细代码 要可以登陆,用数据库保存,第1张

上面给你的是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/htmlcharset=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>

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<link href="main.css" type="text/css" rel="stylesheet">

<title>登陆界面</title>

</head>

<body>

<div class="login_ico">

<img src="images/login_ico.png">

</div>

<div class="login_putin">

<ul>

<li><input type="text" ></li>

<li><input type="password" ></li>

</ul>

</div>

<div class="login_btn">

<input type="submit" value="登陆">

</div>

</body>

</html>

样式 :

*{

margin:0

padding:0}

li{

list-style-type:none

margin:0

padding:0}

a{

text-decoration:none

color:#000}

/*---------------------按钮-----------------------------*/

.login_putin ul li input{

margin: 0

width:70%

padding: 1em 2em 1em 5.4em

-webkit-border-radius:.3em

-moz-border-radius: .3em

border: 1px solid #999

}

.login_btn{

width:300px

margin:40px auto 0 auto

}

.login_btn input{

width:100%

margin:0

padding:.5em 0

-webkit-border-radius:.3em

-moz-border-radius: .3em

border:#1263be solid 1px

background:#1b85fd

color:#FFF

font-size:17px

font-weight:bolder

letter-spacing:1em

}

.login_btn input:hover{

background:#1263be

}

可以用html进行程序编写,从而实现系统登陆界面文本框前有小图案的需求。

可参照以下代码为模板进行编写:完整的代码1:https://download.csdn.net/download/mingzi1245/12406208 代码2https://download.csdn.net/download/mingzi1245/12406204

html是超文本标记语言(英语:HyperText Markup Language,简称:HTML)是一种用于创建网页的标准标记语言。您可以使用 HTML 来建立自己的 WEB 站点,HTML 运行在浏览器上,由浏览器来解析。