Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Need help with asp email and form input data
Old 04-24-2006, 01:22 AM Need help with asp email and form input data
Novice Talker

Posts: 7
Trades: 0
I'm trying to pass form input data to an asp email script. The input data isn't be captured by the asp code. I would really appreciate any help you can give. I have included both the from code and the asp code. For testing purposes, I have commented out all email code. Please review my Response.Write section which will not write any of the variables. Thanks so much for your suggestions and time.

Form htm:

<html>
<head>
<LINK href="style.css" rel=stylesheet>
<script LANGUAGE="JavaScript"><!--
//-->
<!-- This script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return "";
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "email_send.asp";
else if (Subject.selectedIndex == 2) action = "email_send.asp";
else if (Subject.selectedIndex == 3) action = "email_send.asp";
else if (Subject.selectedIndex == 4) action = "email_send.asp";
else if (Subject.selectedIndex == 5) action = "email_send.asp";
else action = "email_send.asp";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</script>
<title>Madison Township Contact Form</title>
<base target="mainFrame">
</head>
<body BGCOLOR="#9E9E9E" link="#CC0033" vlink="#333399" alink="#FF0000"
<!--content start-->
<p align="center"></p>
<table WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="0">
<tr>

<td WIDTH="100%"><P align="center"><font FACE="Times" SIZE="5" Color="#CC0000"> Madison Township Comment Form<BR>
<font FACE="ARIEL,HELVETICA" SIZE="1">
<font FACE="Times" SIZE="2" Color="white">Have something you would like to tell us? &nbsp;Any
comments, suggestions, or questions?
<%Dim mail
%>

<form METHOD="POST" NAME="Mail" ACTION="email_send.asp"
ENCTYPE="text/plain" onSubmit="return formCheck();">
<input type="hidden" name="Info" value>
<table BORDER="0" CELLPADDING="5" CELLSPACING="0">
<tr>
<td><font FACE="ARIEL,HELVETICA" SIZE="2">&nbsp;&nbsp;&nbsp;&nbsp;Name: <input TYPE="text" NAME="Name" onChange="setName()" size="25">
</td>
<td ALIGN="LEFT"><font FACE="ARIEL,HELVETICA" SIZE="2">Subject: <select NAME="Subject" size="1" >
<option SELECT><font FACE="ARIEL,HELVETICA" SIZE="1">Select a subject</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">1) Comment</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">2) Question</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">3) Suggestion</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">4) Miscellaneous</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">5) Website</option>
</select>
</td>
</tr>
<tr>
<td><font FACE="ARIEL,HELVETICA" SIZE="2">Address: <input TYPE="text" NAME="Address" onChange="setName()" size="35"><BR>
<font FACE="ARIEL,HELVETICA" SIZE="2">City: <input TYPE="text" NAME="City" onChange="setName()" size="16">&nbsp;
<font FACE="ARIEL,HELVETICA" SIZE="2">State: <input TYPE="text" NAME="State" onChange="setName()" size="2">&nbsp;
<font FACE="ARIEL,HELVETICA" SIZE="2">Zip: <input TYPE="text" NAME="Zip Code" onChange="setName()" size="8"><BR>
<font FACE="ARIEL,HELVETICA" SIZE="2">Phone Number: <input TYPE="text" NAME="Phone" onChange="setName()" size="15">
<font FACE="ARIEL,HELVETICA" SIZE="2">Email: <input TYPE="text" NAME="email" onChange="setName()" size="45">

<BR><BR><font FACE="ARIEL,HELVETICA" SIZE="2">Would you like someone to contact you?
<INPUT TYPE="radio" NAME="Contact Me" VALUE="Yes">Yes
<INPUT TYPE="radio" NAME="Contact Me" VALUE="No">No
</td>
</tr>
<tr>
<td COLSPAN="2"><font FACE="ARIEL,HELVETICA" SIZE="2">Comments, questions, suggestions, anything!: <BR>
<textarea NAME="Comment" COLS="50" ROWS="4"></textarea>
</td>
</tr>
</table>
<div align="center"><center>
<table>
<tr>
<td align="center">
<input TYPE="submit" VALUE="Send Email">
<Input TYPE="Reset" VALUE="Clear Form">
<script LANGUAGE="JavaScript">

<!-- Begin
getInfo();
getName();
// End -->
</script></font></font></td>
</tr>
</table>
</center></div>
</form>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>

************************************************** *************
email_send.asp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="#808080">
<font size="4" face="Tahoma" color="#FFFFFF">
<%
'Sends an email
Dim mail
Set mail = Server.CreateObject("CDO.Message")
'mail.To = "gclarkox@direcway.com"
'mail.From = Request.Form("email")
'mail.Subject = "Website Email - contact may have been requested"
'mail.HTMLBody ="<h5>Name: </h5>" & Request.Form("name") & "<h5>Subject Selected: </h5>" & Request.Form("subject") & "<h5>Address: </h5>" & Request.Form("address") & "<h5>City: </h5>" & Request.Form("city") & "<h5>State: </h5>" & Request.Form("state") & "<h5>Zip Code: </h5>" & Request.Form("zip code") & "<h5>Contact Me: </h5>" & Request.Form("contact me") & "<h5>Phone #: </h5>" & Request.Form("phone") & "<h5>Question, Request, Comment or Suggestion: </h5>" & Request.Form("comment")
'mail.Send()
Response.Write("Your question, request, comment or suggestion has been sent!")
Response.write("<BR>" & vbNewline)
Response.Write("Your message was: ")
Response.write("<BR>" & vbNewline)
Response.Write(Request.Form("comment"))
Response.Write("Your email address is: ")
Response.write("<BR>" & vbNewline)
Response.Write(Request.Form("email"))

'Destroy the mail object!
Set mail = nothing
%>
<%
' Note that I'm using the Win2000 CDO syntax! I'm
' assuming most people are off of NT4 by now.
' For simplicity and because I'm not letting you enter
' them, I'm not validating email addresses. If you let
' people enter them you should at least do some
' rudimentary level of validation to ensure entries
' are valid.
Dim objMessage

Set objMessage = Server.CreateObject("CDO.Message")
'With objMessage
' Set message attributes
' .To = Request.Form("email")
' .From = "Gene Clark<gclarkox@direcway.com>"
'.From = "Madison Township Trustees <trustees@MadisonTownshipOH.net>"
' .Subject = "Thank you from the Madison Township Trustees"
'.TextBody = "We appreciate you taking the time to contact us. We have received your question, request, comment or suggestion. If you requested to be contacted, one of the township trustees will contact you as soon as possible."
'.CreateMHTMLBody "http://"
' Attachment using known static physical path
'.AddAttachment "c:\somepath\somefile.txt"
' Attachment using mappath to find the physical path
'.AddAttachment Server.MapPath("images/asp101-100x30.gif")
' Attachment added directly from a URL
'.AddAttachment "http://www.asp101.com/samples/images/asp101-100x30.gif"

' Send message - uncomment the following line only
' AFTER you've entered appropriate To and From
' addresses above. Then the script will actually
' send the messages.
' .Send
'End With
Set objMessage = Nothing
%>
</BODY>
</HTML>
GClarkOX is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-24-2006, 04:06 AM Re: Need help with asp email and form input data
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I don't see what you are asking

your response.write lines don't reference any variables and you don't colect any form values any where.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-24-2006, 09:32 AM Re: Need help with asp email and form input data
Novice Talker

Posts: 7
Trades: 0
Thanks for your reply. The ASP script isn't getting information from the form. When the script runs it should display the email address entered in the form. This statement should do this. Response.Write(Request.Form("email"))
I have this working on a host and when I added a function to verify input, it quit working. There is a problem with the sending of email on the host I'm using, which is another issue, but am trying to get the response.write statements to work fo right now. This is why I have the email send code commented out.
GClarkOX is offline
Reply With Quote
View Public Profile
 
Old 04-24-2006, 03:37 PM Re: Need help with asp email and form input data
Novice Talker

Posts: 7
Trades: 0
This thread can be closed. The issue has been resolved. Thanks for the help.
GClarkOX is offline
Reply With Quote
View Public Profile
 
Old 04-24-2006, 06:04 PM Re: Need help with asp email and form input data
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I guess the problem was in the javascript then ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-27-2006, 01:20 PM Re: Need help with asp email and form input data
Novice Talker

Posts: 7
Trades: 0
I took the form validation out of the form and it started working. That is once I figured out the ISP server didn't directly support CDOSYS. They send me code to use another server for CDOSYS and that project working. I'm still purplexed as to why I can't get from data to get validated and passed to the asp script. I'm going to post another example which I may get some help. Thank you so much for your response.
GClarkOX is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help with asp email and form input data
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25214 seconds with 12 queries