Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

irishgrizzly

macrumors 65816
Original poster
May 15, 2006
1,461
2
I'd like to know what flavor of code I'd need to put together a HTML email with a form where depending on the radio button selected it would generate another email response.

e.g.

Do you want?

[•] x
[•] y
[•] z
Submit

(Where each option then sends a different email)
 

Mal

macrumors 603
Jan 6, 2002
6,252
18
Orlando
Here's one example to show how to do the HTML to create an array for the check boxes, and the PHP to interpret it.

PHP won't run from within an email, though, will it?

OP, I think you'll have to kick the user out to a page on your site from a link within the email, instead of embedding this in the email itself. That's of course assuming I read your original post correctly.

jW
 

SailorTom

macrumors regular
May 15, 2008
125
0
never seen a form in an email before, i can't imagine it being very user friendly. I think if i received an email with a form embedded i wouldn't trust it and delete it straight away.

assuming the email client even renders the form correctly, i don't see why you couldn't just set the action attribute to point to a php script on your server. Of course that opens up the possibility of your script being hijacked as it is essentially open to the public, more so than a normal form. Maybe you could use nonce keys to manage this?

I guess another option to try would be hosting the form on your server, and showing it in the email using an iframe, again assuming it renders ok
 

DeViAnThans3

macrumors member
Dec 13, 2010
51
0
Belgium (Europe)
Some mail clients use an external HTML engine in order to show HTML mails. Thus, showing a form should work. Only when you submit something, problems may arise as mail clients simply aren't built for submitting data. You could try with Javascript & AJAX, but most probably it would fail.

Not yet talking about highly restricted webmail services including gmail and hotmail which both throw out Javascript and probably forms-html too. Also not talking about mobile email clients (all the iPhones and androids of this world), which even more likely won't support it.

As suggested earlier, your best bet is to just mail people a link, as that decreases the problem % with a great bunch.

PS: Obviously, PHP can't run within a mail. But you'ld have submitted it to a external PHP page than ;)
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
PHP won't run from within an email, though, will it?

I read his intent that he has a web page where the user interacts with a form, that sends an email. Not using a form inside an email. I figured the thread title just wasn't accurate to what he wanted. If he really does want this implanted in an email, then the whole idea is very bad for many reasons.
 

Mal

macrumors 603
Jan 6, 2002
6,252
18
Orlando
I read his intent that he has a web page where the user interacts with a form, that sends an email. Not using a form inside an email. I figured the thread title just wasn't accurate to what he wanted. If he really does want this implanted in an email, then the whole idea is very bad for many reasons.

Yeah, and if you're correct, then your advice was (as always) very good. I'm hoping I just misinterpreted his intention.

jW
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.