油炸肉圆怎么做比较嫩:网页制作问题

来源:百度文库 编辑:高考问答 时间:2024/04/27 06:27:12
本人已有一个网页,想做一个用户登陆的页面
就是像论坛那种
用户 12345
密码 *****

登陆

这种样子的

数据库已建好user.mdb
希望帮我写一个代码

在这里先谢谢了
(不用注册界面,数据库中已有信息,就是想要一个登陆的页面,还有就是怎么与数据库连接,输入的用户名怎样与数据库中的信息对比)
越详细越好,最好每句都有注释

高分悬赏,成功的话再赏200
如果用户登陆成功的话,登陆到指定的页面
反之则显示用户密码错误
ASP编程

先谢谢ku621 不过我调试的时候说网页有问题

我留下自己的QQ 15240255 可以直接和我联系,加入时 注明baidu知道

数据库两个字段,主建name 另一个password

楼主我也来给一段吧,这是我给客户做网站的时候常用到的一段:
首先是login.asp(这个文件中的内容相信楼主都看得懂吧我就不注释了)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>系统登陆</title>
<link id="style_sheet" href="netsuper.css" type="text/css" rel="stylesheet">
<style type="text/css">
input.a{width:120;height:19;border:1pt solid #666666;}
</style>
<script lanuage="javascript">
function KillSpace(x)
{
//这个函数是JavaScript用来删除表单中文本框中的前后空格
while((x.length>0) && (x.charAt(0)==' '))
{
x = x.substring(1,x.length);
}
while(x.length>0)
{
var s=x.charAt(x.length-1);
if(s==' ')
{
x = x.substring(0,x.length-1);
}
else
{
break;
}
}
return x;
}

function NaNcheckInput()
{
//这个函数是限制文本框只能输入数字
if (event.keyCode >=48 && event.keyCode <=57)
return;

event.keyCode = 0;
}
</script>
</head>

<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#0084DB">
<tr>
<td align="center">
<form name="loginform" method="post" action="checkadmin.asp">
<table width="355" height="145" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border:1pt solid #666666;">
<tr>
<td width="133" height="36" align="right">用户名:</td>
<td width="220" height="36"><input type="text" name="supername" size="15" class=a></td>
</tr>
<tr>
<td height="36" align="right">密 码:</td>
<td height="36"><input type="password" name="superpass" size="15" class=a></td>
</tr>
<tr>
<td height="36" align="right">验证码:</td>
<td height="36"><input type="text" name="verifycode" size="15" style="width:80;height:19;border:1pt solid #666666;">
<img src=getcode.asp width=40 height=10>
</td>
</tr>
<tr align="center">
<td height="36" colspan="2"><input type="submit" value="提交" onclick="return jscheck();"> <input type="reset" value="重置"></td>
</tr>
</form>
<script language="javascript">
function jscheck()
{
return true;
}
</script>
</table>
</td>
</tr>
</table>
</body>
</html>

接下来:checkadmin.asp
<!--#include file="conn.asp"-->
<%
dim username,userpass,verifycode
username=trim(request("supername"))
'获取从login.asp中提交过来的supername文本框中的内容并且用trim函数把前后的空格去掉
userpass=trim(request("superpass"))
'获取从login.asp中提交过来的superpass文本框中的内容并且用trim函数把前后的空格去掉(在实际中我还用了ASP的MD5加密)

verifycode=trim(request("verifycode"))
'获取从login.asp中提交过来的verifycode文本框中的内容并且用trim函数把前后的空格去掉(这里是用了验证码,目的是防止外部恶意提交,而在实际中我还用了SQL防注入程序)

if len(trim(username))=0 or len(trim(userpass))=0 then
response.write "<script language='javascript'>alert('用户名或密码错误,请检查!');window.history.go(-1);</script>"
response.end
end if
'以上这段if then ..end if语句,是先初步检查用户是否输入帐号及密码,如果检查到输入为空则提示出错

if cstr(session("usercode"))<>cstr(trim(request("verifycode"))) then
response.Write "<script LANGUAGE='javascript'>alert('请输入正确的验证码!');window.history.go(-1);</script>"
response.end
end if
'以上这段是检查是否输入了验证码

set rs=server.createobject("adodb.recordset")
'首先创建一个数据连接对象

rs.open "select * from super_user where super_name='"&username&"'",conn,1,1
'这里是打开数据库并查找到super_name等于用户输入的用户名的记录,conn,1,1表示以只读方式打开

if not(rs.eof and rs.bof) then
'如果有查找到相应的记录
if userpass=rs("super_pass") then
'这时候再检查用户输入的密码是否与数据库中一致,如果一至,则生成如下session供后台程序识别
session("aaa")=rs("super_name")
session("bbb")=rs("super_dj")
rs.close
set rs=nothing
response.redirect "main.asp"
'以上这句表示用户登陆成功,系统转向到后台管理主页面
else '如果用户输入的密码不对,则提示错误
response.write "<script language='javascript'>alert('登录失败,请检查用户名、密码及验证码是否正确!');window.history.go(-1);</script>"
response.end
end if
else '如果用户输入的用户名在数据库中没查到,提示出错
response.write "<script language='javascript'>alert('登录失败,请检查用户名、密码、验证码是否正确!');window.history.go(-1);</script>"
response.end
end if
rs.close '关闭数据集对象
set rs=nothing '释放数据集对象资源
%>

附上conn.asp
<%
Response.Buffer = True '禁止缓冲,每次都从服务器中获得最新数据
Dim Conn,ConnStr,MyDbPath,DbFileName,IsSqlDataBase
DIM SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
MyDbPath = ""
IsSqlDataBase=0 '此处设置采用何种数据库,0为MSAccess,1为MSSQL
Server.ScriptTimeout=600 '设置服务器脚本执行时间

If IsSqlDataBase = 1 Then
'========================SQL数据库设置=============================================================
'sql数据库连接参数:数据库名(SqlDatabaseName)、用户名(SqlUsername)、用户密码(SqlPassword)、
'连接名(SqlLocalName)(本地用local,外地用IP)
SqlDatabaseName = "shop"
SqlUsername = "sa"
SqlPassword = "123456"
SqlLocalName = "(local)"
'===================================================================================================
Else
'========================Access数据库设置===========================================================
'用户第一次使用请修改本处数据库地址并相应修改net_ata目录中数据库名称,如:将shop.mdb修改为shop.asp
DbFileName = "data/xxx.mdb"
'===================================================================================================
End If

'这里定义数据库连接方式的过程
Sub Connectiondatabase
If IsSqlDataBase = 1 Then '1表示是采用SQL数据库
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else '否则采用access数据库
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & DbFileName) '这是定义数据库连接字符串,共中Access与SQL不一样哦。
End If
on error resume next '屏蔽错误信息,防止恶意猜解数据库路径
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open ConnStr '开始建立起数据库连接
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
End Sub

'以下过程是定义关闭数据库连接,释放资源减少服务器压力
Sub CloseConn
Conn.close
Set Conn=nothing
End Sub
%>

至此,一个登陆页面加验证页面已完成。。(其中验证码需要一个验证码生成程序和两个图片信息文件,这个在动网论坛里有现成的,直接拿来就可以用)

不过我自己认为,在以上程序中我没有把MD5加密以及SQL防注入程序加上来,是不太安全的,所以楼主在实际应用中还是要把这些加上来,以防恶意攻击。。

<form action="http://地址/bbs/Login.asp" method="POST">
<input type="hidden" value="add" name="menu">
用户名:<input type=text name="UserName" size=8>
密 码:<input type=password name="Userpass" size=8>
<INPUT type=submit value=进入>
<INPUT type=reset value=取消></FORM>

http://地址/bbs/Login.asp 是你论坛的登陆地址
你可以点你论坛的登陆弹出的地址就是
这个是最简单的你可以加上注册地址这个就很简单了比如如果再加上注册地址可以写:
<form action="http://地址/bbs/Login.asp" method="POST">
<input type="hidden" value="add" name="menu">
用户名:<input type=text name="UserName" size=8>
密 码:<input type=password name="Userpass" size=8>
<INPUT type=submit value=进入>
<INPUT type=reset value=取消>
<INPUT type=zhuce.asp value=注册>
</FORM>

zhuce.asp是我自编的你可以写完整的地址比如这个http://5255.102.tofor.com/bbs/reg.asp

<html>
<head>
<script language=vbscript>
<!--
sub chek()
if document.a.a1.value=""then
msgbox"姓名不能为空"
else
if document.a.a2.value<>"" then

docoument.a.submit
else
msgbox"密码不能为空"
end if
end if
end sub

-->
</script>
</head>
<body>
<form action="connection_sql.asp" method="post" name=a>
<p>姓名<input type="text" name="a1"></p>
<p>密码<input type="password" name="a2"></p>

<input type=button name="a3" value="提交" onclick=chek()>

<input type="reset" name="a4" value="重写">
<% call chek()%>
</body>
</html>
connection_sql.asp
<%@language="vbscript"%>
<% name=request.form("a1")
mm=request.form("a2")
set conn=server.createobject("adodb.connection")
strcnn="driver={mircosoft access driver(*.mdb)};dbq="&server.mappath("\") & "\user.mdb ;uid=12345;pwd=12345;dbq=master"
conn.open strcnn
sql="select * from aa where username='"&name&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
while not rs.eof
response.write "此用户的名已被使用!"
rs.movenext
wend
if rs.eof then
rs.addnew
rs("username").value=name
rs("userpassword").value=mm
rs.updatebatch
response.write"添加成功!"
end if
rs.close
conn.close
%>

<html>
<head>
<title>管理员登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Admin_Style.css">
<script language=javascript>
<!--
function SetFocus()
{
if (document.Login.UserName.value=="")
document.Login.UserName.focus();
else
document.Login.UserName.select();
}
function CheckForm()
{
if(document.Login.UserName.value=="")
{
alert("请输入用户名!");
document.Login.UserName.focus();
return false;
}
if(document.Login.Password.value == "")
{
alert("请输入密码!");
document.Login.Password.focus();
return false;
}
if (document.Login.CheckCode.value==""){
alert ("请输入您的验证码!");
document.Login.CheckCode.focus();
return(false);
}
}

function CheckBrowser()
{
var app=navigator.appName;
var verStr=navigator.appVersion;
if (app.indexOf('Netscape') != -1) {
alert("MY动力友情提示:\n 你使用的是Netscape浏览器,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
}
else if (app.indexOf('Microsoft') != -1) {
if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1)
alert("MY动力友情提示:\n 您的浏览器版本太低,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
}
}
//-->
</script>
</head>
<body class="bgcolor">
<p> </p>
<form name="Login" action="Admin_ChkLogin.asp" method="post" target="_parent" onSubmit="return CheckForm();">

<table width="585" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td width="280" rowspan="2"><img src="Images/entry1.gif" width="280" height="246">
</td>
<td width="344" background="Images/entry2.gif"> <table width="100%" border="0" cellspacing="8" cellpadding="0" align="center">
<tr align="center">
<td height="38" colspan="2"><font color="#FFFFFF" size="3"><strong>管理员登录</strong></font>
</td>
</tr>
<tr>
<td align="right"><font color="#FFFFFF">用户名称:</font></td>
<td><input name="UserName" type="text" id="UserName4" maxlength="20" style="width:160px;border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onmouseover="this.style.background='#E1F4EE';" onmouseout="this.style.background='#FFFFFF'" onFocus="this.select(); "></td>
</tr>
<tr>
<td align="right"><font color="#FFFFFF">用户密码:</font></td>
<td><input name="Password" type="password" maxlength="20" style="width:160px;border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onmouseover="this.style.background='#E1F4EE';" onmouseout="this.style.background='#FFFFFF'" onFocus="this.select(); "></td>
</tr>
<tr>
<td align="right"><font color="#FFFFFF">验 证 码:</font></td>
<td><input name="CheckCode" size="6" maxlength="4" style="border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onmouseover="this.style.background='#E1F4EE';" onmouseout="this.style.background='#FFFFFF'" onFocus="this.select(); ">
<font color="#FFFFFF">请在左边输入</font> <img src="inc/checkcode.asp"></td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<input type="submit" name="Submit" value=" 确 认 " style="font-size: 9pt; height: 19; width: 60; color: #000000; background-color: #E1F4EE; border: 1 solid #E1F4EE" onMouseOver ="this.style.backgroundColor='#ffffff'" onMouseOut ="this.style.backgroundColor='#E1F4EE'">

<input name="reset" type="reset" id="reset" value=" 清 除 " style="font-size: 9pt; height: 19; width: 60; color: #000000; background-color: #E1F4EE; border: 1 solid #E1F4EE" onMouseOver ="this.style.backgroundColor='#ffffff'" onMouseOut ="this.style.backgroundColor='#E1F4EE'">
<br>
</div></td>
</tr>
</table></td>
</tr>
<tr><td height="3"></td></tr>
</table>
<p align="center">后台管理页面需要屏幕分辨率为 <font color="#FF0000"><strong>1024*768</strong></font>
或以上才能达到最佳浏览效果!<br>
需要浏览器为<strong><font color="#FF0000"> </font></strong><font color="#FF0000"><strong>IE5.5</strong></font>
或以上版本才能正常运行!!!</p>
</form>
<script language="JavaScript" type="text/JavaScript">
CheckBrowser();
SetFocus();
</script>
</body>
</html>

<html>
<head>
<script language=vbscript>
<!--
sub chek()
if document.a.a1.value=""then
msgbox"姓名不能为空"
else
if document.a.a2.value<>"" then

docoument.a.submit
else
msgbox"密码不能为空"
end if
end if
end sub

-->
</script>
</head>
<body>
<form action="connection_sql.asp" method="post" name=a>
<p>姓名<input type="text" name="a1"></p>
<p>密码<input type="password" name="a2"></p>

<input type=button name="a3" value="提交" onclick=chek()>

<input type="reset" name="a4" value="重写">
<% call chek()%>
</body>
</html>
connection_sql.asp
<%@language="vbscript"%>
<% name=request.form("a1")
mm=request.form("a2")
set conn=server.createobject("adodb.connection")
strcnn="driver={mircosoft access driver(*.mdb)};dbq="&server.mappath("\") & "\user.mdb ;uid=12345;pwd=12345;dbq=master"
conn.open strcnn
sql="select * from aa where username='"&name&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
while not rs.eof
response.write "此用户的名已被使用!"
rs.movenext
wend
if rs.eof then
rs.addnew
rs("username").value=name
rs("userpassword").value=mm
rs.updatebatch
response.write"添加成功!"
end if
rs.close
conn.close
%>
<html>

用asp连
文件名:a.asp
<html>
<head>
<script language=vbscript>
<!--
sub chek()
if document.a.a1.value=""then
msgbox"姓名不能为空"
else
if document.a.a2.value<>"" then

docoument.a.submit
else
msgbox"密码不能为空"
end if
end if
end sub

-->
</script>
</head>
<body>
<form action="connection_sql.asp" method="post" name=a>
<p>姓名<input type="text" name="a1"></p>
<p>密码<input type="password" name="a2"></p>

<input type=button name="a3" value="提交" onclick=chek()>

<input type="reset" name="a4" value="重写">
<% call chek()%>
</body>
</html>
connection_sql.asp
<%@language="vbscript"%>
<% name=request.form("a1")
mm=request.form("a2")
set conn=server.createobject("adodb.connection")
strcnn="driver={mircosoft access driver(*.mdb)};dbq="&server.mappath("\") & "\user.mdb ;uid=12345;pwd=12345;dbq=master"
conn.open strcnn
sql="select * from aa where username='"&name&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
while not rs.eof
response.write "此用户的名已被使用!"
rs.movenext
wend
if rs.eof then
rs.addnew
rs("username").value=name
rs("userpassword").value=mm
rs.updatebatch
response.write"添加成功!"
end if
rs.close
conn.close
%>