首页源码html登录页面代码?html精美登录界面源码

html登录页面代码?html精美登录界面源码

编程之家2026-05-23658次浏览

很多朋友对于html登录页面代码和html精美登录界面源码不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!

html登录页面代码?html精美登录界面源码

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

上面给你的是asp的,这边给你个php的,你看下,不懂再问我

<?php

include("config.php");

session_start();

/*--------------------删除cookies记录,让cookies过期-----------------------------------*/

if($_GET["del"]=="cookies")

html登录页面代码?html精美登录界面源码

{

setcookie("usercookies","", time()-3600);

setcookie("pwdcookies","", time()-3600);

echo"<SCRIPT type=text/javascript>

var n= 5;

var timer= setInterval(function(){

html登录页面代码?html精美登录界面源码

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: ;);

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""">

<html xmlns="">

<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 rel="external nofollow" href="?del=cookies">删除cookies</a>

</body>

</html>

jsp登陆界面源代码

1、login.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*"%>

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登录页面</title>

</head>

<body>

<form name="loginForm" method="post" action="judgeUser.jsp">

<table>

<tr>

<td>用户名:<input type="text" name="userName" id="userName"></td>

</tr>

<tr>

<td>密码:<input type="password" name="password" id="password"></td>

</tr>

<tr>

<td><input type="submit" value="登录" style="background-color:pink"><input

type="reset" value="重置" style="background-color:red"></td>

</tr>

</table>

</form>

</body>

</html>

2、judge.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*"%>

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>身份验证</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name= request.getParameter("userName");

String password= request.getParameter("password");

if(name.equals("abc")&& password.equals("123")){

3、afterLogin.jsp文件

%>

<jsp:forward page="afterLogin.jsp">

<jsp:param name="userName" value="<%=name%>"/>

</jsp:forward>

<%

}

else{

%>

<jsp:forward page="login.jsp"/>

<%

}

%>

</body>

</html>

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登录成功</title>

</head>

<body>

<%

request.setCharacterEncoding("GB18030");

String name= request.getParameter("userName");

out.println("欢迎你:"+ name);

%>

</body>

</html>

扩展资料:

java web登录界面源代码:

1、Data_uil.java文件

import java.sql.*;

public class Data_uil

{

public Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select*from login where username=?";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);

result=preparedStatement.executeQuery();//可执行的查询

if(result.next())

password=result.getString("password");

}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的数据库密码为:"+password);

return password;

}

public void close(Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close(PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2、login_check.jsp:文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>验证用户密码</title>

</head>

<body>

<jsp:useBean id="util" class="util.Data_uil" scope="page"/>

<%

String username=(String)request.getParameter("username");

String password=(String)request.getParameter("password");

if(username==null||"".equals(username))

{

out.print("<script language='javaScript'> alert('用户名不能为空');</script>");

response.setHeader("refresh","0;url=user_login.jsp");

}

else

{

System.out.println("输入的用户名:"+username);

String passwordInDataBase=util.selectPassword(username);

System.out.println("密码:"+passwordInDataBase);

if(passwordInDataBase==null||"".equals(passwordInDataBase))

{

out.print("<script language='javaScript'> alert('用户名不存在');</script>");

response.setHeader("refresh","0;url=user_login.jsp");

}

else if(passwordInDataBase.equals(password))

{

out.print("<script language='javaScript'> alert('登录成功');</script>");

response.setHeader("refresh","0;url=loginSucces.jsp");

}

else

{

out.print("<script language='javaScript'> alert('密码错误');</script>");

response.setHeader("refresh","0;url=user_login.jsp");

}

}

%>

</body>

</html>

3、loginSucces.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

<hr size="10" width="26%" align="left" color="green">

<font size="6" color="red">登录成功</font>

<hr size="10" width="26%" align="left" color="green">

</body>

</html>

4、user_login.jsp文件

<%@ page language="java" contentType="text/html; charset=utf-8"

pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>登录界面</title>

</head>

<body background="C:\Users\win8\workspace\Login\image\9dcbdc339e72a5663b5c289fb5573c13_10.jpg">

<center>

<br><br><br><br><br><br>

<h1 style="color:yellow">Login</h1>

<br>

<form name="loginForm" action="login_check.jsp" method="post">

<table Border="0">

<tr>

<td>账号</td>

<td><input type="text" name="username"></td>

</tr>

<tr>

<td>密码</td>

<td><input type="password" name="password">

</td>

</tr>

</table>

<br>

<input type="submit" value="登录" style="color:#BC8F8F">

</form>

</center>

</body>

</html>

设计一个用户登录页面login.asp

这是我写的一个信息管理系统的登录模块。登录模块和验证密码模块(check)放在了一起。希望对你有帮助。

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!--#include file="../inc/conn.asp"-->

<!--#include file="../inc/function.asp"-->

<%

Response.expires= 0

Response.expiresabsolute= Now()- 1

Response.addHeader"pragma","no-cache"

Response.addHeader"cache-control","private"

Response.cachecontrol="no-cache"

If Request("action")="logout" Then

session("username")=""

session("password")=""

session("classid")=""

session("userlevel")=""

Response.Redirect"../index.asp"

End If

dim username,password,rs,sql,action,yz

set rs=server.createobject("adodb.recordset")

action=trim(request("action"))

yz=request("yz")

If not IsNumeric(Request.Form("yz")) Then

call showErr("你输入的验证码为非数字!")

End If

if isempty(action) or isnull(action) then

response.redirect"admin_login.asp?action='displayFrm'"

end if

select case action

case"login"

call login()

case displayFrm

call LoginFrm()

case else

call LoginFrm()

end select

sub login()

if request("username")="" or request("password")="" or request("yz")="" then

call showErr("请输入正确的的用户名或密码或验证码!")

end if

If(int(Session("GetCode"))=int(Request.Form("yz"))) Then

username=trim(request("username"))

admin_password=trim(request("password"))

username=ProtectSQL(username)

admin_password=ProtectSQL(admin_password)

sql="select* from gradeweb_user where username='"&username&"' and password='"&admin_password&"'"

rs.open sql,conn,3,1

if not(rs.eof and rs.bof) then

if rs("classid")<>"0" then

'如果不是超管,则连接查询班级信息

rs.close

sql="select A.classid,A.userlevel,B.classname,B.gradename,A.username,A.password from gradeweb_user as A INNER JOIN gradeweb_class as B on A.classid=B.classid where A.username='"&username&"'"

sql=sql&" and A.[password]='"&admin_password&"'"

rs.open sql,conn,3,1

end if

else

call showErr("用户名或密码不正确,请认真查证后再输入!")

end if

if rs.eof and rs.bof then

call showErr("用户名\密码不正确,请认真查证后再输入!")

elseif rs("userlevel")="0" then

session.timeout=60

session("userlevel")="0"

session("username")=username

response.Redirect"admin_index.asp"

else

session.timeout=60

session("classid")=rs(0)

session("userlevel")=rs(1)

session("username")=username

session("classname")=rs(2)

session("gradename")=rs(3)

response.redirect"admin_index.asp"

end if

else

call showErr("输入的验证码错误,建议设置浏览器接受COOKIE的安全级别!")

end if

rs.close

end sub

sub LoginFrm()

%>

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""">

<html xmlns="">

<head>

<link rel="stylesheet" rel="external nofollow" href="images/admin/style.css" type="text/css"/>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>

<title>GradeWeb登陆窗口</title>

<script language=javascript>

function CheckLoginFrm()

{

if(document.form1.username.value=="")

{

document.form1.username.focus();

lbluser.innerHTML="<font color=red>用户名不能为空!</font>";

return false;

}

else if(document.form1.password.value=="")

{

document.form1.Password.focus();

lblpass.innerHTML="<font color=red>密码不能为空!</font>";

return false;

}

else if(document.form1.yz.value=="")

{

document.form1.yz.focus();

lblpass.innerHTML="<font color=red>验证码不能为空!</font>";

return false;

}

else return true;

}

</script>

</head>

<html>

<body>

<form id="form1" name="form1" method="post" action="admin_login.asp">

<table width="472" border="1" align="center" cellpadding="5" cellspacing="1" bgcolor="#BFDFFF" id="table2" style="border-collapse: collapse; margin-top:50px;">

<tr id=TableTitle2>

<td colspan="2" valign="middle">管理员登录</td>

</tr>

<tr>

<td width="97">用户名</td>

<td width="346"><input name="username" type="text" size="24" maxlength="16"/><label id="lbluser"></label>

</td>

</tr>

<tr>

<td>密码</td>

<td><input name="password" type="password" size="24"/><label id="lblpass"></label>

</td>

</tr>

<tr>

<td>验证码</td>

<td><input name="yz" type="text" size="4"/>

<img src="GetCode.asp" onclick="this.src='GetCode.asp'"/></td>

</tr>

<tr>

<td colspan="2"><input name="action" type="hidden" value="login"/>

<input name="reset" type="reset" id="reset" value="重写" class=btn/>

<input name="Submit" type="submit" id="Submit" value="确定" class=btn onclick="javascript:return CheckLoginFrm()"/><label id="lblyz"></label>

</td>

</tr>

</table>

</form>

</body>

</html>

<%end sub%>

END,本文到此结束,如果可以帮助到大家,还望关注本站哦!

openai人工智能,open ai是什么百度ai免费写作?百度AI写作功能在哪里