Implement web BBS with ASP (Repost)

xiaoxiao2021-03-05  23

Most of the traditional web BBS is implemented in CGI mode. Its implementation requires that the programmer must master the programming language such as Perl or C, and understand the technical content of the CGI mode, so it is really difficult to make your own web BBS. Not small. The appearance of the ASP (Active Server Pages Dynamic Server Home) makes our eyes bright, can you use the ASP to implement web BBS? The answer is of course affirmative. The tempting of ASP is that it provides an easy-to-learn script and has many built-in objects that provide a simple programming path.

This BBS is mainly registered (browser), user registration (server side), plus sub-(browser), plus subscription (server side), post specific content display and reply, and all posts show six parts Where the user information is stored in the database author.mdb, the post is stored in the database bbs.mdb. They are all ACCESS databases, as shown in Table 1, respectively, Table 2. Table 1 Author.mdb

Field Name Data Type Length Description Authname Text 24 User Name Password Text 10 Password

Table 2 bbs.mdb

Field name data type length Description ID text 4 Posts number authname Text 24 User name Subject text 80 Topic Content Remarks Content AddDate Date / Time Adaption Date Num Digital Long Total Number Answernum Text 4 Reply Post Number (Default The number for itself) AddTIME Date / Time PAC TOPNUM text 4 First Layer number Reply Post No

The specific implementation method is as follows, in which the ASP file and data inventory are placed in "/ hosp / asp", other HTM files are stored in the "/ hoSP" file, the IMG file is stored in "/ hosp / images".

1. User registration (browser) login.htm: Enter relevant information by the user to transfer to the server via a form.

register a new user </ title> <head> <body> <form method = "post" action = "/ hosp / asp / register.asp"> <p> <h2> for Easy to sign up, please register a user name </ h2> User: <input type = "text" name = "name" size = "24"> <p> password: <input type = "password" name = "password" Size = "24"> <p> <input type = Submit value = "registration"> <input type = reset value = "Clear"> <a href="/hosp/asp/dispbbs.asp"> Back to Forum </ A> <p> </ body> </ html></p> <p>2, user registration (server side) register.asp: Receive form information with Request.form ("Family Belt Name), use ADO technology to connect with the database author.mdb, and store form information into Author.mdb. <html> <head> <title> Save User Information </ Title> </ head> <body> <! <! <% Name = Request.form ("Name") Code = Request.form ("Password") <! - with author.mdb connection -> set connection = server.createObject ("adodb.connection" connection.open "Author" set = connection.execute (" Select * from author ") <! - If the username already exists, please reload, otherwise deposit into the database -> if not rs.eOf life%> This username has been registered, please re-<a href = "/HOSP/Login.htm"> Register </A> New Username! <% elseConnection.execute ("INSERT INTO AUTHOR (Authname, Password) Values ​​('" & name & ",'" & code & ")") RS .CloseConnection.close%> <center> <b> <% = Name%> </ b> You have been registered successfully! <P> <a href="/hosp/ASP/Dispbbs.asp"> Back to Forum </ a > </ Center> <% END IF%> </ body> </ html></p> <p>3, plus sub-(browser) BBS_ADD.HTM: Enter information about the post to be added to the server by the user.</p> <p><html> <head> <title> a sample form </ title> </ head> <body background = "/ hoSP / images / backgrior.gif"> <form method = "action =" / hosp / asp / BBS.ASP> <P> Name: <input name = "name" size = "28"> password: <input type = "password" name = "code" size = "28"> <p> topic: <Input Name = "Subject" size = "66"> <p> content: <p> <textarea name = "content" rows = 20 cols = 72> </ textarea> <p> <center> <input type = Submit value = "Release Information"> <input type = reset value = "Clear Information"> </ center> </ form> </ body> </ html> 4, plus sub-(server side) bbs.asp: receive the contents, and Store in bbs.mdb.</p> <p><html> <head> <title> bbs.asp </ title> </ head> <body> <% name = request.form ("name") code = request.form ("code") Subject = request.form ("Subject") Content = Request.form ("Content") curdate = datecurtime = time <! - Connection with Author.mdb -> set connections = server.createObject ("adodb.connection" Connection.open "Author "SET RS = Connection.execute (" SELECT * AUTHOR WHERE Authname = '"& Name &"' and password = '"& code") <! - Decision user name and password match -> if not rs.eof THEN! Open the data file, save the number of the post, add a post, number plus 1 -> set fileObject = server.createObject ("scripting.filesystemObject") set instream = fileObject.opentextFile ("C: /inetpub/wwwroot/hosp/asp/data.id ", 1, false, false) Number = cstr (Instream.Readline 1) set outstream = fileObject.createtextfile (" c: / inetpub / wwwroot / hosp / asp / data .id ", True, False) OutStream.WriteLine numberIf Request.QueryString (" ID ") =" "Thenmanswernum = numberElsemanswernum = Request.QueryString (" ID ") End IfIf Request.QueryString (" topnum ") =" "Thenmtopnum = Numberelsemtopnum = Request.QueryString ("Topnum") end ifset outstream = Nothing <! - Put the post information into the database -> set connbbs = server.createObject ("adoDb.connection" connbbs.open "bbs" connbbs.execute ("Insert Into BBS (ID) , Authname, Subject, Content, Adddate, ADDTIME, ANSWERNUM, TOPNUM, VITNUM, VALUES ('"& Number &",' "& Name &", '"& Subject &",' "& Content &"</p> <p>',' "& curdate &", '"& manswernum &",' "& mtopnum &" 0) ") connbbs.close%> <% = curdate &"%> <% = curtime & " Add Post "%> <a href="http://nt-server/hosp/asp/dispbbs.asp"> Back to Forum </a <p> Name: <% = Name%> <P> Topic: <% = Subject%> <P> content: <% = content%> <p> <% else%> Your username or password is wrong, please re-export! <% end ifrs.closeConnection.Close%> </ Body> </ html> 5, post specific content display and reply Detail.asp</p> <p><html> <head> <title> bbs.asp </ title> </ head> <body background = "/ hoSP / images / backgrior> <% idnum = request.queryString (" id ") set connection = Server.createObject ("AdoDb.Connection") Connection.open "BBS" set = connection.execute ("SELECT * from bbs where id = '" & idnum & "")%> Name: <% = rs (1)% > <p> topic: <% = rs (2)%> <p> content: <% = rs (3)%> <p> ------------------ -------------------------------------------------- ---------- <! - Form Reply Form -> <% Resub = "Re:" & RS (2) MtopNum = rs (8) rs.closeConnection.Close%> <form method = "POST" action = "/ hOSP / ASP / BBS.ASP? ID = <% = IDNUM%> & TOPNUM = <% = mtopNum%>> <P> Name: <input name =" name "size =" 28 " > Password: <input type = "password" name = "code" size = "28"> <p> topic: <input name = "Subject" size = "66" value = "<% = resub%>> < P> Content: <p> <textarea name = "content" rows = 20 COLS = 72> </ textarea> <p> <center> <input type = Submit value = "Information Reply"> <input type = reset value = "Clear Information"> </ center> </ form> <a href="http://nt-server/hosp/ASP/Dispbbs.asp"> Back to Tool </a> </ body> </ html> 6 All posts Dispbbs.asp: List all the subjects, authors, time, access to the number of posts.</p> <p><html> <head> <title> Dispbbs.asp </ title> </ head> <body background = "/ hoSP / images / backgrior.gif"> <center> <img src = "/ hosp / images / luntan. GIF "border = 0> </ center> <p> <center> <a href="/hosp/login.htm"> <img src =" / hoSP / images / zhuce.gif "border = 0> </ a > <a href="/hosp/bbs_add.htm"> <img src = "/ hosp / images / jiatz.gif" border = 0> </a> <a href="/hosp/default.htm"> < IMG SRC = "/ hosp / images / return.gif" Border = 0> </a> </ center> <p> <% set connection = server.createObject ("adodb.connection") Connection.Open "BBS" SET RS = Connection.execute ("Select * from bbs where id = answernum order") set conn = server.createObject ("adoDb.connection") Conn.open "BBS" set rsnext = conn.execute ("SELECT * From bbs ") Do while not rs.eof%> <% = rs (0)%> <a href="/hosp/asp/detail.asp?id=<% =rs (0)%> <% = RS (2)%> </a> - <font size = "4"> <b> <% = rs (1)%> </ b> </ font> <% = rs (4) & "" %> <% = Rs (7)%> (<% = RS (5)%>) <p> <% set rExt = conn.execute ("SELECT * from bbs where topnum <> id and opnum = '" & r (0) & "'Order By ID ASC") Do While Not Rsnext.eof%> <% = rsnext (0)%> <a href="/hosp/asp/detail.asp?id=<% =rsNext (0)%> RE <% rsNext (6)%>: <% = rsnext (2)%> </A> - <font size = "4"> <b> <% = rsnext (1)%> <</p> <p>/ B> </ font> <% = rsNext (4) & "%> <% = rsNext (7)%> (<% = rsNext (5)%>) <p> <% rsnext.movenextLooprs.MovenextLooprsNext. Closeconn.close.closeConnection.Close%> </ body> </ html> The above program is implemented on WIN NT4.0 and IIS3.0.</p> <p><script src = "../../ 2.js" type = "text / javascript"> </ script></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-39179.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="39179" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'XXbVz4AV7wAyYSMVJ_2FMllKIbey2_2B3on6K6rzYwM6MOt3Yc9STr_2BCqhtgZyVnQrgOuHqqa3UN9FhMELwo'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>