Simple ASP Forum DIY

Source: Internet
Author: User

First use access to create a new database, named Luntan, the name of the datasheet is "information", establish the following fields: "Text", "name", "Time", and set the "time" default value to now ()

<%

Set com = Server.CreateObject ("ADODB.") Connection ")

Com.open "Driver={microsoft Access DRIVER (" Luntan.mdb ");

Pwd=information;dbq= "&server.mappath (" Luntan.mdb ")

Sql= "Select*from Information order by Time Desc"

Set rs=server.createobject ("ADODB. Recordest ")

Rs.Open sql,com,3,2

If Rs. EOF or Rs. BOF Then

Response.Write "No messages."

Else

Rs. MoveFirst

While not Rs. Eof.

Response.Write rs ("name") & "posted on" &rs ("Time") & "<br>"

Response.Write rs ("text") & "<br>

Rs. MoveNext

Wend

Absoluteposition=n, (n=1,2,3 ...)

End If

%>

Then the user writes the message section. Set the Forum page as "information.asp", then

<form method=post action= "information.asp" >

Name: <input type=text size=12 name= "name" ><br>

Message: <textarea cols=30 row=4 name= "text" ></textarea><br>

<input type=submit value= "Submit" >

</form>

The last part is to log the user-submitted form data to the database,

<%

If request ("text") <>empty and request ("name") <>empty Then

Set comb=server.createobject ("ADODB. Connection ")

Comb. Open "Driver={microsoft Access DRIVER (*.mdb)};p wd=information;

Dbq= "&server.mappath (" Luntan.mdb ")

Sql= "Select*from Information"

Set rsb=server.createobject ("ADODB. Recordset ")

Rsb.open sql,comb,3,2

RSB. AddNew

RSB ("text") =request ("text")

RSB ("name") =request ("name")

Rsb.update

End If

%>



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.