Traditional Culture Encyclopedia - Travel guide - Seek ASP simple source code!

Seek ASP simple source code!

Ultra-simple code, suitable for getting started, ***6 files, in which data.mdb is the database file, enter.htm is the login interface, ent_submit.asp is the file to judge whether the login can be successful, login.asp is the page to jump to after the login is successful, registered is the interface for registered members, and reg_submit.asp is the file to handle the registration information.

1.enter.htm file

& lt! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 1 Transitional//EN "

" http://www . w3 . org/TR/html 4/loose . dtd " & gt;

& lthtml & gt

& lthead & gt

& ltmeta http-equiv = " Content-Type " Content = " text/html; charset=gb23 12 " >

& lttitle & gt untitled document

& lt/head & gt;

& ltbody & gt

& ltform name = " form 1 " method = " post " action = " ent _ submit . ASP " >

& ltp & gt& lt/p & gt;

& ltp> User Name:

& ltinput name = " username " type = " text " id = " username " size = " 20 " >

& lt/p & gt;

& ltp> secret code:

& lt enter name = "password" type = "password" id = "password" size = "16" >

& lt/p & gt;

& ltp & gt

& lt enter type = "submit" name = "submit" value = "login" >

& ltahref = "register.htm"> Register as a member.

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;

2.ent_submit.asp file

& lt% @ LANGUAGE = " VBSCRIPT " code page = " 936 " % & gt;

& lt! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 1 Transitional//EN " " http://www . w3 . org/TR/HTML 4/loose . DTD " & gt;

& lthtml & gt

& lthead & gt

& ltmeta http-equiv = " Content-Type " Content = " text/html; charset=gb23 12 " >

& lttitle & gt untitled document

& lt/head & gt;

& ltbody & gt

& lt%

set conn = server . createobject(" adodb . connection ")

conn . open " driver = { Microsoft access driver(*。 MDB)}; dbq = " & ampserver.mappath("data.mdb ")

User name =request.form ("user name")

password = request . form(" password ")

SQL = " select * from user where username = ' "+username+" ' and password = ' "+password+" ' "

Set rs = server. CreateObject("adodb.recordset ")

Connecticut, 1, 3

If rs.eof, then

Response. Write ("< script & gtAlert ('User name or password is wrong, please re-enter!') ); history . back(- 1)& lt; /script & gt; ")

other

Response. Write ("< Script & gt Alert ("Login successful! " ); history . back(- 1)& lt; /script & gt; ")

response.redirect"login.asp "

If ... it will be over.

Rs off

Set rs = none

Connection closed

Set connection = none

% & gt

& lt/body & gt;

& lt/html & gt;

3.login.asp document

& lt! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 1 Transitional//EN " " http://www . w3 . org/TR/HTML 4/loose . DTD " & gt;

& lthtml & gt

& lthead & gt

& ltmeta http-equiv = " Content-Type " Content = " text/html; charset=gb23 12 " >

& lttitle & gt untitled document

& ltstyle type="text/css " >

& lt! -

. style 1 {

font-size: 18px;

Font thickness: bold;

}

-& gt;

& lt/style & gt;

& lt/head & gt;

& ltbody & gt

& ltdiv align="center " >

& ltp & gt& lt/p & gt;

& ltp & gt& lt/p & gt;

& ltp & gt& lt/p & gt;

& ltp & gt& lt/p & gt;

& ltp class="style 1 "> successfully logged in and went to this page.

& lt/div & gt;

& lt/body & gt;

& lt/html & gt;

4.register.htm document

& lt! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 1 Transitional//EN "

" http://www . w3 . org/TR/html 4/loose . dtd " & gt;

& lthtml & gt

& lthead & gt

& ltmeta http-equiv = " Content-Type " Content = " text/html; charset=gb23 12 " >

& lttitle & gt untitled document

& ltstyle type="text/css " >

& lt! -

. style 1 { font-size: 14px }

-& gt;

& lt/style & gt;

& lt/head & gt;

& ltbody class="style 1 " >

& ltform name = " form 1 " method = " post " action = " reg _ submit . ASP " >

& ltp & gt& lt/p & gt;

& ltp> User Name:

& ltinput name = " username " type = " text " id = " username " size = " 20 " >

& lt/p & gt;

& ltp> secret code:

& lt enter name = "password" type = "password" id = "password" size = "16" >

& lt/p & gt;

& ltp & gt

& lt enter type = "submit" name = "submit" value = "register" >

& ltahref = "enter.htm"> Return to the login page.

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;

5.reg_submit.asp file

& lt%

set conn = server . createobject(" adodb . connection ")

conn . open " driver = { Microsoft access driver(*。 MDB)}; dbq = " & ampserver.mappath("data.mdb ")

User name =request.form ("user name")

password = request . form(" password ")

exec = " select * from user where username = ' " & amp; User name and password "

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

Connecticut, 1, 1

If username = ""or password = ""then

Response. Write ("< script & gtAlert ('User name or password cannot be empty!' ); history . back()& lt; /script & gt; ")

other

If not, then

Response. Write ("< script & gtAlert ('Sorry, this account has been registered, please re-enter!') ); history . back()& lt; /script & gt; ")

other

Sql="insert into user(username, password) value ("+username+", "+password+") "

Connect. execute sql

response . write(" & lt; Script & gtAlert ('Registration successful!' ); history . back()& lt; /script & gt; ")

If ... it will be over.

If ... it will be over.

Rs off

Set rs = none

Connection closed

Set connection = none

% & gt

6.data.mdb file

This requires you to build an ACCESS database named data.mdb. If you don't need to install ACCESS, please install it first, and then create a table named USER in data.mdb. The table fields are as follows:

Id: automatic numbering

User name: text type

Password: text type