willem_e7 Posted March 30, 2010 Share Posted March 30, 2010 Hello all. I have a simple PHP contact form that I've been using for a while. I would like to know if it's possible to have check box options in my HTML page when using the form that would allow users to select which person to contact. So basically, based on the check box option, the php form would submit the information to a variation of 5 email addresses. Is this possible? Thanks if anyone can steer me in the right direction! Link to comment https://forums.phpfreaks.com/topic/196991-php-contact-form-with-options/ Share on other sites More sharing options...
Jax2 Posted March 30, 2010 Share Posted March 30, 2010 Sure it's possible. Give each separate checkbox it's own unique name, such as checkbox name=admin [email protected] Checkboxes only pass information when they're checked, so you can do a simple check on the processing page: if (isset(_$POST['admin'])) { $to=$_POST['admin'] } Or, if you have multiple, use case/switch. Link to comment https://forums.phpfreaks.com/topic/196991-php-contact-form-with-options/#findComment-1034164 Share on other sites More sharing options...
andrewgauger Posted March 30, 2010 Share Posted March 30, 2010 Yes. If you want to hard-code the email addresses into the php you can just: <input type=checkbox name=email[] value="[email protected]">[email protected]<br> <input type=checkbox name=email[] value="[email protected]">[email protected]<br> Then the php side would be: $fromEmail="[email protected]"; $toDefault="[email protected]"; $emails=$_POST['email']; $header="From: $fromEmail \r\n"; foreach ($emails as $email){ $header=$header."CC: $email"; if (!($email==$emails.end)) $header=$header . " \r\n"; } mail($toDefault, $subject, $message, $header); Note: I didn't define $subject or $message so this won't work until you morph it into your needs. Link to comment https://forums.phpfreaks.com/topic/196991-php-contact-form-with-options/#findComment-1034170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.