ASP Programming Basics (11): Chat program

Source: Internet
Author: User
Tags servervariables
The common Chat room program, that is, the Chat program, does not use the basic structure of the database. So what technology is used? We know that the Session variable in ASP variables is used to record the information of a single user and track user behavior. The Application object acts as a global variable, multiple users on the site can share information on the page.
As you can imagine, in the current chat program, a chat member is a Session variable, and sessions between chat members are shared and displayed as Application variables so that all members can see them.
Next we will use a classic instance program for understanding and analysis.
1. chat. asp
<% If Request. ServerVariables ("Request_Method") = "GET" then %>
<Form method = "post" action = "chat. asp">
<Input type = "text" name = "nick" value = "your nick name"> <p>
<Input type = "submit" value = "come in"> <p>
<Input type = "hidden" name = "log" size = "20" value = "1">
</Form>
<% Response. End
Else
Response. clear
Dim talk
If Request. Form ("nick") <> "then
Session ("nick") = Request. Form ("nick ")
End if
%>
<Form method = "post" action = "chat. asp" name = form1>
<% = Session ("nick") %> speaker:
<Input type = "text" name = "talk" size = "50"> <br>
<Input type = "submit" value = "submit">
<Input type = "reset" value = "cancel"> </p>
</Form>
<A href = "chat. asp"> exit </a> <br>
<%
If Request. Form ("log") <> 1 then
If trim (Request. Form ("talk") = "" then
Talk = Session ("nick") & "don't say a word, you just want to give it away"
Else
Talk = trim (Request. Form ("talk "))
End If
Application. lock
Application ("show") = "from" & Request. serverVariables ("remote_addr") & "& Session (" nick ") &" in "& time: "& talk &" <br> "& Application (" show ")
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.