Huitzilopochtli
Programmer
Hello
This is a guestbook and the idea behind the code which I've pasted below is that if the person wanting to write something in the guestbook leaves off his name, or EMail address, etc, this page reminds him to go back to complete
the details.
Unfortunately, the "Please click here to type in your Email address" appears even when the visitor HAS filled in the e.mail details, and if the visitor forgets, say, to type a message (or whatever), he gets a page saying:
"Please click here to type in your message""Please click here to type in your Email address" in other words, the site visitor gets BOTH messages. How can I ensure that the
"Please click here to type in your Email" doesn't appear on every page, and how can I ensure that only those messages which are appropriate appear, so that if a visitor does forget to type his name he will get:
"Please click here to type in your name" (and not BOTH messages)??
Grateful thanks.
The code is:
<%@ Language=VBScript %>
<%option explicit%>
<!--#include file="Connection.asp"-->
<HTML>
<HEAD>
<style type="text/css">
a:link {color:#191970;}
a:visited {color:#191970;}
a:active {color:#191970;}
</style>
</HEAD>
<BODY>
<center>
<%
dim objRS, strSQL
dim strName, strSubject, strMessage, strEmail, strDate, strTime
strSQL = "SELECT * FROM Forum"
set objRS = server.CreateObject("ADODB.RecordSet"
objRS.Open strSQL, objConn,1,2
strName = Request.Form("txtName"
strSubject = Request.Form ("txtSubject"
strMessage = Request.Form ("txtMessage"
strEmail = Request.Form("txtEmail"
strDate = (Date)
strTime = (Time)
strMessage = Replace(strMessage,chr(10),"<BR>"
if strName = "" OR strMessage = "" OR strSubject = "" OR strEmail = "" then
if strName = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</A> to type in your name"
Response.Write ("</font>"
end if
if strSubject = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your subject"
Response.Write ("</font>"
end if
if strMessage = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your message"
Response.Write ("</font>"
end if
if strEmail = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your Email address"
Response.Write ("</font>"
end if
Response.End
end if
objRS.AddNew
objRS("Name" = strName
objRS("Subject" = strSubject
objRS("Message" = strMessage
objRS("Email" = strEmail
objRS("Date" = strDate
objRS("Time" = strTime
objRS.Update
Response.Write "<center>The guestbook has been updated with your message</center>"
Response.Write "<center>Please click <a href='gbook.asp'>here</A> to go back to the guestbook</center>"
%>
</center>
</BODY>
</HTML>
This is a guestbook and the idea behind the code which I've pasted below is that if the person wanting to write something in the guestbook leaves off his name, or EMail address, etc, this page reminds him to go back to complete
the details.
Unfortunately, the "Please click here to type in your Email address" appears even when the visitor HAS filled in the e.mail details, and if the visitor forgets, say, to type a message (or whatever), he gets a page saying:
"Please click here to type in your message""Please click here to type in your Email address" in other words, the site visitor gets BOTH messages. How can I ensure that the
"Please click here to type in your Email" doesn't appear on every page, and how can I ensure that only those messages which are appropriate appear, so that if a visitor does forget to type his name he will get:
"Please click here to type in your name" (and not BOTH messages)??
Grateful thanks.
The code is:
<%@ Language=VBScript %>
<%option explicit%>
<!--#include file="Connection.asp"-->
<HTML>
<HEAD>
<style type="text/css">
a:link {color:#191970;}
a:visited {color:#191970;}
a:active {color:#191970;}
</style>
</HEAD>
<BODY>
<center>
<%
dim objRS, strSQL
dim strName, strSubject, strMessage, strEmail, strDate, strTime
strSQL = "SELECT * FROM Forum"
set objRS = server.CreateObject("ADODB.RecordSet"
objRS.Open strSQL, objConn,1,2
strName = Request.Form("txtName"
strSubject = Request.Form ("txtSubject"
strMessage = Request.Form ("txtMessage"
strEmail = Request.Form("txtEmail"
strDate = (Date)
strTime = (Time)
strMessage = Replace(strMessage,chr(10),"<BR>"
if strName = "" OR strMessage = "" OR strSubject = "" OR strEmail = "" then
if strName = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</A> to type in your name"
Response.Write ("</font>"
end if
if strSubject = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your subject"
Response.Write ("</font>"
end if
if strMessage = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your message"
Response.Write ("</font>"
end if
if strEmail = "" then
Response.Write ("<font face='verdana' size='2' color='navy'>"
Response.Write "Please click <a href='javascript:history.back(1)'>here</a> to type in your Email address"
Response.Write ("</font>"
end if
Response.End
end if
objRS.AddNew
objRS("Name" = strName
objRS("Subject" = strSubject
objRS("Message" = strMessage
objRS("Email" = strEmail
objRS("Date" = strDate
objRS("Time" = strTime
objRS.Update
Response.Write "<center>The guestbook has been updated with your message</center>"
Response.Write "<center>Please click <a href='gbook.asp'>here</A> to go back to the guestbook</center>"
%>
</center>
</BODY>
</HTML>