Make a simple chat room with ASP

Source: Internet
Author: User
Tags interface reset
Chat | chat room

This time I introduced to you is my first to use ASP to do the program----chat room, very simple, no database, but for the comrade has not learned ADO is a good reference example, this example basically includes the ASP's five built-in objects, but with the prototype of the chat room, If the level of home can be done on the basis of the strong good-looking point good, nonsense do not say, now go to the topic!

First of all, this program has four parts, respectively, index.asp,chat.asp,show.asp,input.asp first call chat.asp and then you can run!

As a beginner, I think it's important to write a whole idea of a program, that is to say, you first have to determine what function to implement, and then the various functions of the block and solve, then as a simple chat room, I think the first to have a landing interface, after landing into a chat room main interface, the main interface is divided into two blocks , the top piece is the content of the chat display, the following piece is the word written by the chat and sent.

Determine the various functional sections, and then we each to achieve! OK, first to solve the login interface bar, this easy, HTML casually make a form, I do is very simple:

<title> Welcome to Small chat rooms </title>
<meta Http-equiv=content-language content=zh-cn>

<body topmargin=150 bgcolor=ffffff>
<table border=1 align= "center" cellpadding=0 cellspacing=0 height=200>
<tr>
&LT;TD align=center > Chat room User Login </td>
</tr>
<tr>
&LT;TD Align=center height=162>
<form method=post action= "chat.asp" >
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td></td>
</tr>
<tr>
&LT;TD width=37% align=center> User name </td>
&LT;TD width=63%>
<input type= "text" name= "userid" size=19 maxlength= "ten" >
</td>
</tr>
<tr>
&LT;TD > Password </td>
<td>
<input type= "password" name= "password" size=19 "maxlength=" >
</td>
</tr>
          
<td>
<p align=center><input type=submit value= "Landing" name= "Submit" >
<input type=reset value= "rewrite" Name=reset >
</td>
</tr>
<tr>
&LT;TD ></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
&LT;TD align=center><a href=http://www.webjx.com target= "_blank" >www.webjx.com</a></td>
</tr>
</table>
</body>

Well, after doing such a simple landing page, we go to the homepage of the production.

Above we made a simple landing page, now start to do our main interface chat.asp:

<%
Name=request.form ("userid")
Password=request.form ("password")
Response.Cookies ("CNAME") =name
Session ("Sname") =name
If Name= "" Then
Response.Redirect "Index.asp"
End If
%>
<frameset rows=80%,20%>
<frame name= "Show" src= "show.asp" >
<frame name= "Input" src= "input.asp" >
</frameset>

The main implementation of this program is to extract index.asp form data, and then determine whether the user has to fill in the user name, if not back to the login interface, but also set up cookies and session variables for other file calls.

After we do it, we turn to writing input.asp file, which is the part of user input chat content:

<title> Welcome to Small chat rooms </title>
<body>
<meta Http-equiv=content-language content=zh-cn>
<form method= "POST" action= "show.asp" target= "Show" >
<p><font=ffff00><%=request.cookies ("CNAME")%></font>
said: <input type= "text" Name=putword size= ">"
<input type= "Submit" Name=formsubmit value= "Send" >
<input type= "reset" Name=formreset value= "re-hair" >
</font>
</body>

This code is very simple, there is a place where beginners may not understand, target is the implementation of the content will be written to show the framework, rather than be directly in their own frame! The reader can experience the removal of target, and then we'll do the last part, the show.asp part.

<%
Mytalk=trim (Request.Form ("Putword"))
If mytalk<> "" Then
Application.Lock
Application ("show") = "<font color=0000ff size=4>" &
Request.Cookies ("CNAME") & "</FONT>:" & "<font size=3>"
& MyTalk & "</font>" & "<br>" & Application ("Show")
Application.UnLock
End If
%>
<title> Welcome to Small chat rooms </title>
<body>
<meta Http-equiv=content-language content=zh-cn>
<pre>
<%=application ("show")%>
</pre>
</body>

Because there is no application database, the main part of this code is to use application to achieve chat content to share good, very simple a chat room done, hehe! Don't be laughed at!



Related Article

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.