PDA

View Full Version : useing forms inside email!


Crash1hd
05-21-2003, 04:33 AM
THe following code for some reason doesnt work

<%

Dim MessageBody, objMail

MessageBody = "<LINK href='http://www.alwaysremember.ca/Scripts/style.css' rel='stylesheet' type='text/css'>"
MessageBody = MessageBody & "<p align='center'><a name='Top' href='http://www.Alwaysremember.ca'><img name='Title' src='http://www.Alwaysremember.ca/Images/title.gif' alt='Title' border='0'></a></p><br>"
MessageBody = MessageBody & "Welcome " & First_Name & " " & Last_Name & " to <a name='Top' href='http://www.Alwaysremember.ca'>Alwaysremember.ca</a><br><br>"
MessageBody = MessageBody & "<b><a href=http://www.Alwaysremember.ca/Login/register.asp?emc='" & email & "'&uid=" & userid & ">Please click here to confirm your registration and activate your account:</a></b>"
MessageBody = MessageBody & "<hr>"
MessageBody = MessageBody & "&nbsp;&nbsp;&nbsp;Username: " & username & "<br>"
MessageBody = MessageBody & "&nbsp;&nbsp;&nbsp;Password: " & pass & "&nbsp;&nbsp;&nbsp; *Don't forget your password*<br>"
MessageBody = MessageBody & "<hr>"
MessageBody = MessageBody & "Remember to never give out you password<br><br>"
MessageBody = MessageBody & "Thankyou for registering with us!<br><br>"
MessageBody = MessageBody & "Adam Kirk<br>Customer Service Manager<br><a name='Top' href='http://www.Alwaysremember.ca'>Alwaysremember.ca</a><br><br>"
MessageBody = MessageBody & "Please feel free to contact us at <A href='mailto: customerservice@alwaysremember.ca' target=_blank>customerservice@alwaysremember.ca</A>"
MessageBody = MessageBody & "<br><br><br><br><br><br><br><br><p align='center'>If you have recieved this email and you never requested this <a href=#>click here</a></P>"


MessageBody = MessageBody & "<form name='Confirm' action='http://www.Alwaysremember.ca/test2.asp' method='post'>"
MessageBody = MessageBody & "<input type='text' name='Confirm' value='01'>"
MessageBody = MessageBody & "<input type='submit' name='Members' value='Update'>"
MessageBody = MessageBody & "</form>
s

Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.To = email
objMail.From = "registrar@alwaysremember.ca"

objMail.Subject = "Registration Email Confirmation for Alwaysremember.ca"
objMail.BodyFormat = 0
objMail.MailFormat = Request.Form("MailFormatField")
objMail.Body = MessageBody
objMail.Send
Set objMail = Nothing
%>

The part in red doesnt work?

raf
05-21-2003, 08:39 AM
The ending of that red piece of code can't be correct. Think you need to put a double quote after the closing form-tag and remove the 's'
Also. This will print values surrounded by singe quotes. It's better to follow html standard and have doube quotes. Like
MessageBody = MessageBody & "<form name=""Confirm"" action=""http://www.Alwaysremember.ca/test2.asp"" method=""post"">"

Crash1hd
05-21-2003, 09:07 AM
Actually the s and the missing " are not part of the real code lol I dont know how that happened when I posted it!

Ok so it opens the page fine but for what ever reason useing the following code on test2.asp I dont get to see the value 01

<%
If Request.Form("Confirm") <> "" Then
Response.write Request.Form("Confirm")
End If
%>

raf
05-21-2003, 12:26 PM
Insert this in test2.asp. It will print all names of the posted formfields + there values. Fastest way to see which variabels and values are posted. I don't see anything wrong, though it's probably a bad idea to name the form with the same name as a formfield


dim formfield
for each formfield in request.form
response.write(formfield & " = " & request.form(formfield) & "<br />")
next


also, the "If Request.Form("Confirm") <> "" Then".
I'd replace it by
If Len(Request.Form("Confirm")) > 0 then

Crash1hd
05-21-2003, 09:26 PM
Ok I tried that but when you goto the page from the email
(Clicking on the button in the email which takes me to the page)

it still doesnt show anything when I click on the button on the page it works fine (maybe it has something to do with the email program)??

raf
05-22-2003, 09:07 PM
Aaahh. So you want to have the form in the mail and post it to your server. Hmm. Never did that.

Never will to, because;
- not everyone uses html based messages, so they mis out on all the fun
- you'll get synchronisation problems. Say i get the mail, end fill in the form a few days later. You could have changed your processing time inbetween. (if you'll never change it, it wount be very flexible)
- what if they read there mails ofline
- the message will be to big (scrolling etc)

So, why not have a simple link to your site (to the formspage on your server)?

Why it doesn't work? Have you tryed it by using the "get" method?

whammy
05-24-2003, 01:04 AM
raf has some very good points... before sending a form like that, I'd be absolutely sure of a few things:

1. The user is able to receive HTML email at that email address
2. The user checks his emails online at that address (I know some people who download it then get offline immediately... although I can't relate with that since I have cable, and it's always on)
3. You've tested it in every possible email client (that supports HTML)

Otherwise, just sending a plain old text link (with querystring values in it) is probably the best way to go. ;)

Crash1hd
05-24-2003, 06:54 AM
Oh I agree! what I wanted to do was send hidden form values then use a link not a button but I was useing a button as a test cause useing a link would just complicate things at first lol ;)

The only thing I dont like about useing querystring is that the values are right inside the url!

raf
05-25-2003, 10:48 PM
The only thing I dont like about useing querystring is that the values are right inside the url!
True. But this only creates problems on shared computers.
(could be in the browsers history ... and could show up in the users adress bar if another user types in part of the pageadress)

Anyway, i'd just include a link to a formpage and have the user put in his info there.