Passing Strings (email address) from form to PHP
Passing Strings (email address) from form to PHP
I have a php contact form and all works great going to a single address but I'm trying to modify my script to handle a drop down selector, which enables choosing a recipient (which email address to send to).
Here is the part of the code that I have so far in trying to deal with this issue:
I'm sure my problem lies in the calling/getting the value of recipient but I can't figure out where to go from here.
Answer by Verhaeren for Passing Strings (email address) from form to PHP
You're trying to do something weird here. It should be:
if ($_POST['recipient'] == 1) { $to = 'soandso@mail.com'; } else if($_POST['recipient'] == 2) { $to = 'soandso@mail.com'; } else if($_POST['recipient'] == 3) { $to = 'soandso@mail.com'; } else { echo 'Sorry for no recipient'; }
Of course 'recipient'
will never be equal to 1, 2 or 3.
I also noticed the form
and the select
has the same name 'recipient'. I don't know is that is an issue though. But I would like to address it anyway.
Answer by csaw for Passing Strings (email address) from form to PHP
Your form name and select name is the same. also you are echoing the post value inside the select. i think it is left over from your previous input box.
try this;
Answer by Pascal Ruscher for Passing Strings (email address) from form to PHP
This code is working 100% :
(function($) { $('#recipient').on('click', function() { $('#recipient-form').submit(); }); })(jQuery);
Answer by Nathan for Passing Strings (email address) from form to PHP
The page in it's (mostly) entirety for clarification purposes hopefully:
Please complete the missing item(s) indicated.
Sorry, Messages sent that contain links will not be sent.
Sorry, there was a problem sending your message. Please try again later.
Your message has been sent. Thank you for your message!
0 comments:
Post a Comment