Recommended: What to do if the database is restricted? I don't know if you have encountered such a space since the scriptures. It limits the size of your database. For example, ACCESS MYSQL is limited to less than 100M. What if you feel that this space is very affordable, but the database is limited and you want to use such space? Because I have encountered it myself
After a stage of Asp learning, we will build a simplest chat room based on the content we have learned. Although it is very simple, you can master the basic process of establishing a chat room through it and continuously improve its functions.
The main steps are described below:
1. Add the code in the Global.asa file. This part of the code mainly processes the Application_onStart event. In this event, a data with 15 elements is defined and assigned to the properties of an Application object. The content of the Global.asa file is as follows.
| The following is the quoted content: <SCRIPT LANGUAGE=VBScript RUNAT=Server> SUB Application_OnStart dim maChats(15) defines a data with 15 elements. Application(gaChats)=maChats Stores the content of the conversation. Application(giCounter)=0 Stores the number of existing conversations. END SUB </SCRIPT> |
2. Add code in the AspChat.asp file. Note that you need to add this part of the code between two horizontal lines in the homepage, that is, between two <hr> in the text. The program first determines whether the Post method is used when applying for this homepage, because the window submission method in this example is post. Generally, when applying for this homepage for the first time, the get method is used. So if the post method is used, it means that a certain browser reapply when submitting his own conversation content, which needs to be processed because there is a new conversation content. Otherwise, it means that a certain browser applied for this homepage for the first time and did not submit any conversation, so it only needs to display the current conversation content.
| The following is the quoted content: <p align=center><font size=5> A simple chat room</font></p> <br> <% Process input if Request.ServerVariables(Request_Method)=POST then Sign the speaker if len(Request(txtWho))>0 then Session(ssWho)=Request(txtWho) end if Block Application Objects Application.Lock Create a local reference pointer mlCounter=Application(giCounter) maChats=Application(gaChats) If the number of lines written exceeds 10, start counting again. if mlCounter>9 then mlCounter=0 end if Increase user input, increase counter by 1 maChat(mlChounter)=Session(ssWho)&:&Request(txtCents) mlCounter=mlCounter 1 Set local variables to be valid within application scope. Applicati giCounter)=mlCounter Application(gaChats)=maChat Eliminate Application object blocking Application.Unlock end if %> <% Write to TextArea if Application(giCounter)=0 then lstemp=Application(gaChats)(0) else for x=0 to Application(giCounter)-1 lstemp=lstemp&<br>Application(gaChats)(x) next end if Response.white lstemp %> <hr> |
3. Finally, initialize the content of txtWho. That is, when the browser enters his or her name once, he or she does not need to enter it again. In order to distinguish each different viewer, a Session object is used here. The name of the viewer is recorded using Session (ssWho). The following code is directly written below the above code and stored in AspChat.asp.
| The following is the quoted content: <form method=POST action=aspchat.asp name=frmAsp> <div align=center><center><p>Speech: <input type=text name=txtCents size=34></p> </center></div><div align=center><center><p>Object: <input type=submit value=send name=B1></p> </center></div> </form> |
4. Complete. Just add the complete htm file code before and after the 2 and 3 steps and save it as aspchat.asp. This is a very simple asp chat room program. You can continuously enhance its functions as you learn!
Share: How to write a website statistics system using ASP Most of the current website statistics systems are CGI, but they are very complicated to write. ASP is simple to learn and has the advantages of combining with databases. Therefore, based on the website statistics system I have done before, let’s discuss with you the ASP writing website statistics system. Everyone