软件教程

用Asp实现单页查询数据库

来源: 本站    类别: 软件教程    日期: 2016/5/3

 

<!-- #include file="../conn.asp" -->
<%
dim rs,sql,x_name,x_pwd,x_count
If Request.Form("do")="ok" Then
If Request.Form("user_name")="" Then
Response.Write("<script Language='javascript'>alert('对不起,请输入用户名!\t');history.go(-1);</script>")
Response.End()
Else
x_name = Request.Form("user_name")
End If
'↑ 叛断用户名是否为空!
If Request.Form("user_pwd")="" Then
Response.Write("<script Language='javascript'>alert('对不起,请输入用户密码!\t');history.go(-1);</script>")
Response.End()
Else
x_pwd = Request.Form("user_pwd")
End If
'↑ 叛断用户密码是否为空!
set rs = Server.Createobject("adodb.recordset")
sql="select * from [user] where user_name='"&x_name&"' and user_pwd='"&x_pwd&"'"
rs.open sql,conn,1,1
if not rs.Eof Then
session("s_name")=rs("user_name")
session("s_shen")=rs("shenfen")
session("s_shi")=rs("shijian")
Response.Redirect "infoin.asp"
Else
Response.Write("<script language='javascript'>alert('对不起,用户或密码错误!\t');history.go(-1);</script>")
Response.End()
End If

Else
%>

<title>-->系统登录</title>
<style type="text/css">
<!--
.zi {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 10pt;
}
-->
</style>
<p> </p>
<p> </p>
<p>   </p>
<p> </p>   
   
 <table width="320" height="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#33CCFF" class="zi">
  <tr>
    <td colspan="2">-->系统登录</td>
   </tr>
   <form name="form1" method="post" action="index.asp">
  <tr bgcolor="#FFFFFF">
    <td width="72"><div align="center">帐号:</div></td>
    <td width="239">
      <input name="user_name" type="text" id="user_name">
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td><div align="center">密码:</div></td>
    <td><input name="user_pwd" type="password" id="user_pwd"></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td> </td>
    <td><input type="submit" name="Submit" value="登 录">
      <input type="button" name="Submit" value="关 闭" >
      <input name="do" type="hidden" id="do" value="ok"></td>
  </tr>
  </form>
  <tr>
    <td colspan="2"><div align="right">v1.00</div></td>
   </tr>
</table>
<%End If%>


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com