Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 25th, 2003, 08:58 AM
Authorized User
 
Join Date: Jul 2003
Location: Houston, Texas, USA.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nvillare
Default Chat Room Creation HELP!

I am trying to create a basic chat room and am having much difficulty. Can anyone please help?

Code:
<%@ language="VBScript"%>

<%
'if form has not been submitted it will ask you to enter a chat name
if isempty(Request.Form("OK")) then
   theMessage1 = "Enter the name you would like to go by during this chat:"
else
'code runs when the form is submitted
'check if chat name has been entered
 if isempty (Request.Form("chatName")) or Request.Form("chatName") = "" then
   theMessage1 = "Please enter a Chat Name."
 else
 'connection is established
 'session variable chatname is set to name supplied by user
 Session("chatName") = Request.Form("chatName")
 'text of thread is set to an empty string
 Session("Thread") = ""

 set RSLastEntry = MyConn.Execute("select Max(ChatID) as MaxID from ChatRoom")
 'checks to see the last entry in the dbs
 'if none then it is set to 0
   if isnumeric(RSLastEntry("MaxID")) then
   Session("LastEntry") = RSLastEntry("MaxID")
   else
   Session("LastEntry") = 0
   end if
 'user is directed to the chat page
 Response.Redirect "chat.htm"
 end if
end if

%>

<html>
<head>
<title>Live Chat Room</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<center><span class="top"><b>Welcome to the Chat Room</b></span>
</center><p>
<form action="../../private/chatRoom/index.asp" method="post">
  <p class="btext">
<% Response.Write theMessage1 %><p>
<input type="text" name="chatName" size="25" maxlength="22"><p>
<input type="submit" value="OK" name="OK">
</form>
</body>
</html>

chat.htm is a frameset with two frames

body.asp --
<%@ Language=VBScript %>

<%
'connection included to the db, retrieve any new threads
 'retrieve any new entries entered after the last entry was received

 set RSMessage = Server.CreateObject("ADODB.Recordset")
 MySQL = "SELECT ChatID, Message FROM ChatRoom WHERE ChatID > " & Session("LastEntry")
 RSMessage.Open MySQL, conn

'code loops through each record
 while RSMessage.Eof = false
'append new message to the current thread
 Session("Thread") = Session("Thread") & RSMessage("Message") & chr(13)
 'next time page refreshes it will not grab the old message
 Session("LastEntry") = RSMessage("ChatID")
 RSMessage.MoveNext
 wend
%>

<html>
<head>
<title>Body for the Chat Room</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="15">
</head>
<body>
<p><span class="otext"><b>Chat Window</b></span><p>
<textarea rows=13 cols=70 name="chatWindow" WRAP=VIRTUAL readonly>
<% Response.Write Session("Thread") %></textarea>
</body>
</html>

and footer.asp --
<%@ Language=VBScript %>

<%
if isempty(Request.Form("Submit")) then
 'initial message to the user
 'listed in html part
 TheMessage1 = "Please use the form below to sign the guestbook."
 TheMessage2 = "Note that fields with *** are required."
 TheMessage3 = ""
else
'temporary variables to hold the data
 theName = Request.Form("theName")
 Email = Request.Form("Email")
 Location = Request.Form("Location")
 Comments = Request.Form("Comments")

'check validation of Name
  if isempty (Request.Form("theName")) or Request.Form("theName") = "" then
   TheMessage1 = "The form was not submitted."
   TheMessage2 = "Name is required!"

  'check validation of email
  elseif isempty(Request.Form("Email")) or Request.Form("Email") = "" then
   TheMessage1 = "The form was not submitted."
   TheMessage2 = "Email Address is required!"

  elseif instr(Request.Form("Email"), "@") = 0 or instr(Request.Form("Email"), ".") = 0 then
   TheMessage1 = "The form was not submitted."
   TheMessage2 = "Email address is invalid!"
else

 'form has been submitted
 'send info to database
 TheMessage1 = "Thanks " & theName & " for signing my book"
 TheMessage2 = "Your entry will be reviewed prior to posting."
 TheMessage3 = "<a href='guestBook.asp'>View the Guestbook</a> " & " || " & " <a href='signBook.asp'>Return Home</a>"

 'combine the message to send to my email address
 'EmailMessage = "Sign-In entry to be reviewed for posting:" & chr(13) & chr(13)
  '13 creates a new line in the message
 'EmailMessage = EmailMessage & "Name: " & theName & chr(13)
 'EmailMessage = EmailMessage & "Email Address: " & Email & chr(13)
 'EmailMessage = EmailMessage & "Location: " & Location & chr(13)
 'EmailMessage = EmailMessage & "Comments: " & Comments & chr(13)

 'set connection to email the message
 'set objMail = CreateObject("CDONTS.NewMail")
 'send message to my email address
 'parameter is to who, from, subject, message
 'objMail.Send "nidia_villarreal@oxy.com", Request.Form("Email"), _
 '"New Entry into the GuestBook!", cstr(EmailMessage)
 'destroy the objMail
 'set objMail = nothing

 'insert data into the database
 dim MySQL
 MySQL = "INSERT INTO SignIn (theDate, theName, Email, Location, Comments)"
 MySQL = MySQL & " VALUES ('" & Date() & "','"
 MySQL = MySQL & theName &"','"
 MySQL = MySQL & Email &"','"
 MySQl = MySQL & Location &"','"
 MySQL = MySQL & Comments &"')"

 conn.Execute(MySQL)

 end if
end if
%>

<html>
<head>
<title>Sign Guest Book</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><center>
<% Response.Write TheMessage1 %><br>
<% Response.Write TheMessage2 %><p>
<% Response.Write TheMessage3 %></center>

  <% if TheMessage1 <> "Thanks " & theName & " for signing my book" then%>

<p>
<form method="post" action="signBook.asp" name="sign">
<table align="center" width="65%" border="0" bordercolor="#CC9900" cellspacing="6" cellpadding="10">
    <tr>
      <td width="35%">Name:***</td>
  <td><input type="text" name="theName" value="<%= theName %>" size="30" maxlength="28"></td>
</tr>
<tr>
  <td>E-mail Address:***</td>
  <td><input type="text" name="Email" value="<%= Email %>" size="30" maxlength="28"></td>
</tr>
<tr>
  <td>Location:</td>
  <td><input type="text" name="Location" value="<%= Location %>" size="30" maxlength="28"></td>
</tr>
<tr>
  <td valign="top">Comments:</td>
  <td align="left"><textarea rows="4" cols="40" name="Comments" value="<%= Comments %>"></textarea></td>
</tr>
<tr>
  <td colspan=2><center><input type="submit" value="Submit" name="Submit"></center></td>
</tr>
</table>
</form>
<% end if %>
</body>
</html>


Any help is greatly appreciated!!

Thanks!

nvillare
__________________
Thanks!

N
Reply With Quote
  #2 (permalink)  
Old August 25th, 2003, 08:45 PM
Authorized User
 
Join Date: Jun 2003
Location: Quezon City, MM, Philippines.
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to planeswalk
Default

Hi,

It would greatly help if you can point out the exact problem you're having.




Marlon Villarama
Support Team
Web Burner Hosting
marlon@webburner.com
www.webburner.com
Toll-Free: 877-535-2876
Reply With Quote
  #3 (permalink)  
Old August 28th, 2003, 06:46 AM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe a stupid question but why this:

MySQL = MySQL & Comments &"')"

 conn.Execute(MySQL)

 end if <---
end if
%>


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chat Room aliusmankhan ASP.NET 2.0 Professional 2 August 23rd, 2008 07:51 AM
GUI chat room mralam Java GUI 4 October 30th, 2007 04:46 AM
Online Chat Room pro-logic .NET Web Services 0 October 20th, 2003 05:26 AM
Chat Application uxi ASP.NET 1.0 and 1.1 Professional 1 October 1st, 2003 08:39 AM
Chat Room Trouble nvillare Classic ASP Basics 0 July 11th, 2003 03:58 PM



All times are GMT -4. The time now is 06:58 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.