It is not difficult to implement functions, but it is difficult to improve or even perfect.
Therefore, I will post the function implementation and discuss with all beginners. As for perfection, it depends on your own ideas
1. Create a database
It started, I built a database called windsn.mdb, containing 4 tables
admin table (used for administrator information): id, name (user name), pwd (password), ...
Concent table (used to store document data): con_id, title, author, part, con, time, num
con_id automatic numbering
title
author author or source
part article classification
con Article content
time publication time (using =now() as the initial value)
num Number of times read
part table (used to store document classification data): id, part (category), num
reply table (for document comments): con_id, rep_id, rep_name, rep_con, rep_time
con_id The field corresponding to the con_id field in the table concentration, the number type
rep_id automatic numbering
rep_name Username participating in the comment
rep_con comment content
rep_time Comment time
Connect to database file conn.asp
| Here is the code snippet: <% Setconn=Server.CreateObject("ADODB.Connection") conn.Open"DRIVER={Microsoft AccessDriver(*.mdb)};DBQ="&Server.MapPath("db/windsn.mdb") %> |
Then, add a line of code before each page to connect to the database: <!--#include file="../Conn.asp" -->
2. Set session
In order to prevent illegal login, we need to create a session.asp.
| Here is the code snippet: <% ifsession("name")=""then 'If the username does not exist, restrict login. (You can also set another field to increase security) 'If you are the only administrator, then the name above can be changed to ifsession("name")<>"yourname"'then, so the security will be higher, and there is no need to worry about loopholes, but it will be inflexible. response.write"<script>alert('Sorry, you are not logged in yet!'); location='http://www.windsn.com/admin.asp'</script>" response.end endif %> |
At that time, add a line of code before each page: <!--#include file="session.asp" -->
3. Administrator login
1. Login interface
Log in to the admin.asp file, I set it to check.asp to verify