Click to See Complete Forum and Search --> : email sign-up from home page


jmarshall
06-14-2005, 07:50 PM
Hi,

I want to add a real simple email text box and submit button to a home page for a site I am working on, to collect emails for people who want to get info. on their upcoming events. I am VERY green w/ ASP ... can anyone give me some direction as to the best way to do this? I am guessing set-up the simple form fields on my home page and then would need to create an asp page to process it - I am not very familiar with writing that code though.

Thank you!!

buntine
06-14-2005, 08:11 PM
You pretty much have the right idea.

You will need to set up a basic HTML form on your Web Site. Just ask for the users email and name. From there, you will process the data and store it with an apropriate medium.

There are a few different ways to store the data, the most popular being a database. You could also use a flat file (or XML file), have the details emailed to you, etc.

Have you any preferance?

Regards.

jmarshall
06-14-2005, 08:15 PM
Hi,

Thanks ... I just want to send a simple email to the manager of the restaurant, he is going to keep track of them - if it looks like we get a good response we may visit using a database to store them, but for now - real simple :-) I was just playing around w/ some code I found - probably butchered it but here it is ...

Simple HTML page for right now:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<html>

<form method=post action=sendmail.asp>
<input type="hidden" name="recipient" value="JGill@NewportDesignStudio.com">
<input type="hidden" name="subject" value="Reservation Request - Pilgrim House">
<input type="hidden" name="body" value="email sign-up">
From email: <input type=text name=sender><br>
<input type=submit>
</form>

</body>
</html>

ASP Page (I don't think I am setting this up correctly)

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

<body>
set mail=server.CreateObject("CDONTS.NewMail")
mail.From= Request("sender")
mail.To = Request("recipient")
mail.Subject = Request("subject")
mail.Body = Request("body")
mail.Send
set mail=nothing
</body>
</html>

jmarshall
06-14-2005, 08:16 PM
I say real simple ... not meaning the ASP part :-)

buntine
06-14-2005, 08:22 PM
All ASP code must be enclosed in <% and %>. So your ASP page should look like:

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

<body>
<%
set mail=server.CreateObject("CDONTS.NewMail")
mail.From= Request("sender")
mail.To = Request("recipient")
mail.Subject = Request("subject")
mail.Body = Request("body")
mail.Send
set mail=nothing
%>
</body>
</html>

Regards.

jmarshall
06-14-2005, 08:24 PM
Yeah!! It just worked!! Thanks very much :-)

buntine
06-14-2005, 08:28 PM
No worries. ;)

jmarshall
06-14-2005, 08:32 PM
Quick question, I want to do a redirect so it stays on the home page ... I just added:

<input type="hidden" name="redirect" value="http://www.vinaliaboston.com"> in my html page but it is going to http://www.vinaliaboston.com/sendmail.asp

I did not add anything to the ASP page, I am thinking I need to though ... right?

wmif
06-14-2005, 08:38 PM
after the mail processing put this line in:

response.redirect("index.html")

or you can use the absolute path:
response.redirect("http://www.vinaliaboston.com")

jmarshall
06-14-2005, 09:02 PM
Thank you!! You have been very helpful!!