ASP login interface connect to Access database

Source: Internet
Author: User

1, (index.asp User login page)
<!--#include file= "conn.asp"-
<!--blog.soowooo.cn Long Holidays--
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Members </title>
<style type= "Text/css" >
<!--
body,td,th {
Font-family: Song body;
font-size:14px;
}
-
</style>
<body>
<center>
<p> member Registration System </p>
<form name= "Form1" method= "Post" action= "Login.asp" >
<table width= "34%" border= "0" >
<tr>
&LT;TD width= "33%" height= ">" username:</td>
&LT;TD width= "67%" height= "" "><input name=" username "type=" text "id=" username "size=" ></td> "
</tr>
<tr>
&LT;TD height= "@" > Password:</td>
&LT;TD height= "><input name=" password "type=" password "id=" password "size=" ></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><input type= "Submit" name= "Submit" value= "OK" >
<input type= "reset" name= "Submit" value= "reset" ></td>
</tr>
<tr>
&LT;TD colspan= "2" ><a href= "reg.asp" target= "_self" > Registration </a></td>
</tr>
</table>
</form>
</center>
</body>


2, (login.asp user Data Processing file)

<!--#include file= "conn.asp"-
<%
' Open the database to determine if the user exists, info is the table name, username is the field name
Set Rsc=server.createobject ("Adodb.recordset")
Sqlc= "SELECT * from info where username= '" &request. Form ("username") & "' and Password= '" &request. Form ("password") & "'"
Rsc.open sqlc,conn,1,1
Session ("username") =RSC ("username")
Session ("Password") =RSC ("password")
Session. Timeout=30
Set rsc=nothing
Response. Redirect ("change.asp")
' If the user does not exist, the session ("username") is empty
%>
3, (change.asp User Information modification page)
<!--#include file= "conn.asp"-
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Modify </title>
<style type= "Text/css" >
<!--
body,td,th {
font-size:14px;
}
-
</style><center>
<body>
<br>
<%

Set Rsc=server.createobject ("Adodb.recordset")
Sqlc= "SELECT * from info where username= '" &session ("username") & "' and Password= '" &session ("password") & "'"
Rsc.open sqlc,conn,1,1
NR=RSC ("password")
USERNAME=RSC ("username")
PASSWORD=RSC ("password")
SEX=RSC ("Sex")
QQ=RSC ("QQ")
MAIL=RSC ("Mail")
ADD=RSC ("Add")
PERSONALINFO=RSC ("Personalinfo")
VV=RSC ("Ntime")
Set rsc=nothing
If nr= "" Then
Response. Redirect ("index.asp")
End If
If StrComp (nr,request. Form ("password")) =0 Then
Response. Write ("Welcome!" "&request. Form ("username"))
Response. Write ("You are in" &vv& "registered")
Session ("username") =request. Form ("username")
End If
If session ("username") = "Then
Response. Redirect ("index.asp")
End If
%>
<form name= "Form1" method= "Post" action= "Change.asp?ac=ch" >
<table width= "39%" height= "border=" 0 ">
<tr>
&LT;TD width= "27%" height= ">" username:</td>
&LT;TD width= "73%" height= "" "><input name=" username "type=" text "id=" username "value=" <%=username%> " >
*</td>
</tr>
<tr>
&LT;TD height= "@" > Password:</td>
&LT;TD height= "><input name=" password "type=" text "id=" password "value=" <%=password%> ">
*</td>
</tr>
<tr>
&LT;TD height= "A" > Gender:</td>
&LT;TD height= "><input" name= "Sex" type= "text" id= "Sex" value= "<%=sex%>" ></td>
</tr>
<tr>
&LT;TD height= ">QQ:</td>"
&LT;TD height= "><input" name= "QQ" type= "text" id= "QQ" value= "<%=qq%>" ></td>
</tr>
<tr>
&LT;TD height= ">Mail:</td>"
&LT;TD height= "><input" name= "Mail" type= "text" id= "Mail" value= "<%=mail%>" ></td>
</tr>
<tr>
&LT;TD height= ">" Address:</td>
&LT;TD height= "><input" name= "Add" type= "text" id= "Add" value= "<%=add%>" ></td>
</tr>
<tr>
<td> Introduction </td>
<td><textarea name= "Personalinfo" cols= "" "rows=" 6 "id=" Personalinfo "><%=personalinfo%></ Textarea></td>
</tr>
<tr>
<td> </td>
<td><input type= "Submit" name= "Submit" value= "Modify" >
<a href= "Change.asp?se=y" target= "_self" > Exit system </a></td>
<% if StrComp (request. QueryString ("se"), "Y") =0 Then
Session ("username") = ""
Response. Redirect ("index.asp")
End If
%>
</tr>
</table>
</form>
<%
If StrComp (request. QueryString ("AC"), "ch") =0 Then
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from info where username= '" &session ("username") & "'"
Rs.Open sql,conn,1,3
RS ("username") =request. Form ("username")
RS ("password") =request. Form ("password")
RS ("Mail") =request. Form ("Mail")
RS ("Sex") =request. Form ("Sex")
RS ("QQ") =request. Form ("QQ")
RS ("Add") =request. Form ("Add")
RS ("Personalinfo") =request. Form ("Personalinfo")
Rs.update
Set rs=nothing
Response. Write ("Modify complete! ")
End If
%>
</body>
</center>
4, (reg.asp New User registration page)
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> User Registration </title>
<style type= "Text/css" >
<!--
body,td,th {
Font-family: Song body;
font-size:14px;
}
-
</style>
<body>
<center>
User Registration <br>
<%
=request. QueryString ("MSG")
%>
<form name= "Form1" method= "Post" action= "Addnewdata.asp?ac=adduser" >
<table width= "39%" height= "border=" 0 ">
<tr>
&LT;TD width= "27%" height= ">" username:</td>
&LT;TD width= "73%" height= "" "><input name=" username "type=" text "id=" username ">
*</td>
</tr>
<tr>
&LT;TD height= "@" > Password:</td>
&LT;TD height= "><input name=" password "type=" password "id=" password ">
*</td>
</tr>
<tr>
&LT;TD height= ">" OK password:</td>
&LT;TD height= "><input name=" password2 "type=" password "id=" Password2 ">
*</td>
</tr>
<tr>
&LT;TD height= "A" > Gender:</td>
&LT;TD height= "><input" name= "Sex" type= "text" id= "Sex" ></td>
</tr>
<tr>
&LT;TD height= ">QQ:</td>"
&LT;TD height= "><input" name= "QQ" type= "text" id= "QQ" ></td>
</tr>
<tr>
&LT;TD height= ">Mail:</td>"
&LT;TD height= "><input" name= "Mail" type= "text" id= "Mail" ></td>
</tr>
<tr>
&LT;TD height= ">" Address:</td>
&LT;TD height= "><input" name= "Add" type= "text" id= "Add" ></td>
</tr>
<tr>
<td> Personal Introduction </td>
<td><textarea name= "Personalinfo" cols= "rows=" 6 "id=" Personalinfo "></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type= "submitted" name= "submit" value= "Submission" ></td>
</tr>
</table>
</form>
</center>
</body>
5, (addnewdata.asp New user registration data processing file)
<!--#include file= "conn.asp"-
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Success </title>
<body>
<%
Ac=request. QueryString ("AC")
Msg= "Registration error message"
If request. Form ("username") = "Then
msg=msg& "<br>" & "user name cannot be empty"
End If
If StrComp (CStr (Request. Form ("password")), CStr (request. Form ("Password2")) <>0 Then
msg=msg& "<br>" & "two times password input is different"
End If

If Len (Request. Form ("password")) <6 Then
msg=msg& "<br>" & "Password Too simple"
End If

If StrComp (MSG, "Registration error message") >0 Then
Response. Redirect ("reg.asp?msg=" &msg)
End If
If ac= "AddUser" Then
Set Rsc=server.createobject ("Adodb.recordset")
Sql= "SELECT * from info where username= '" &request. Form ("username") & "'"
Rsc.open sql,conn,1,1
CK=RSC ("username")
Set rsc=nothing
If ck<> "" Then
msg=msg& "<br>" & "user name is registered"
Response. Redirect ("reg.asp?msg=" &msg)
End If
Dsql= "SELECT * from info where ID is null"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open dsql,conn,1,3
Rs.addnew
RS ("username") =request. Form ("username")
RS ("password") =request. Form ("password")
RS ("Mail") =request. Form ("Mail")
RS ("Sex") =request. Form ("Sex")
RS ("QQ") =request. Form ("QQ")
RS ("Add") =request. Form ("Add")
RS ("Personalinfo") =request. Form ("Personalinfo")
RS ("Ntime") =now
Rs.update
Set rs=nothing
%>
<center>
<a href= "index.asp" target= "_self" > Registration successful, click Login </a>
</center>
<%
End If
%>
</body>

6, (conn.asp database connection file)
<%
' Connect database start
Dim conn,rs,sql
On Error Resume Next
Dbpath=server.mappath ("Userinfo.mdb")
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &dbpath
' Create Record object
Set Rs=server.createobject ("Adodb.recordset")
%>

7, (Userinfo.mdb ACCESS database)
Build a table in Access, and then create a field name in the table
Table Name: Info

Field name data type
ID Auto Number
Username text
Password text
Sex text
Quest Text
QQ text
Mail text
Personalinfo text
Ntime text

ASP login interface connect to Access database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.