A form in a HTML email

Discussion in 'Web Design and Development' started by irishgrizzly, Jan 28, 2011.

  1. irishgrizzly macrumors 65816

    irishgrizzly

    Joined:
    May 15, 2006
    #1
    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)
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    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.
     
  3. Mal macrumors 603

    Mal

    Joined:
    Jan 6, 2002
    Location:
    Orlando
    #3
    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
     
  4. SailorTom macrumors regular

    Joined:
    May 15, 2008
    #4
    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
     
  5. DeViAnThans3 macrumors member

    Joined:
    Dec 13, 2010
    Location:
    Belgium (Europe)
    #5
    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 ;)
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    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.
     
  7. Mal macrumors 603

    Mal

    Joined:
    Jan 6, 2002
    Location:
    Orlando
    #7
    Yeah, and if you're correct, then your advice was (as always) very good. I'm hoping I just misinterpreted his intention.

    jW
     

Share This Page