Jump to content

For To Email [addresses]


Recommended Posts

Hi There Can anyone please help me? :) I want a one form to go thru to different email addresses!Let me explain the form I have has 3 select options on it to send emails to as per the example below<form action="captcha.php" method="post">Name: <input name="name" type="text" id="name">Surname: <input name="surname" type="text" id="surname">Tel: <input name="tel" type="text" id="tel">E-mail: <input name="email" type="text" id="email">Send email to: <select name="to" id="town"><option value=" john @johnemail.co.za">John</option><option value=" chris @chrisemail.co.za">Chris</option><option value=" danny @dannyemail.co.za">Danny</option></select></form>And here is the captcha.php page example<?if ($_SERVER["REQUEST_METHOD"] <> "POST") die("You can only reach this page by posting from the html form");// *** The text input will come in through the variable $_POST["captcha_input"],// while the correct answer is stored in the cookie $_COOKIE["pass"] ***if ($_POST["captcha_input"] == $_SESSION["pass"]){// *** They passed the test! ***// *** This is where you would post a comment to your database, etc ***echo "Thank you! You have entered the correct code. <br><br>";echo "Your information has been sent as follows:<br><br>";echo "Your Name: \"" . $_POST["name"] . "\" <br>";echo "Your Surname: \"" . $_POST["surname"] . "\" <br>";echo "Your Tel: \"" . $_POST["tel"] . "\" <br>";echo "Your Send E-Mail to: \"" . $_POST["to"] . "\" <br>";echo "Your E-mail: \"" . $_POST["email"] . "\" <br>"; //sends email via php to the following address$to = $_POST['to'];$mailuser = "".$to."";$mailusers = " john @johnemail.co.za “;//echo 'default chosen address: '.$mailuser;$header = "Return-Path: ".$mailuser."\r\n"; $header = "Bcc: ".$mailusers."\r\n"; $header .= "From: $_POST \r\n"; $header .= "Content-Type: text/html;"; $mail_body = 'name: '. $_POST[name] . '<br>surname: '. $_POST[surname] . '<br>tel: '. $_POST[tel] . '<br>Emailto: '. $_POST[to] . '<br>email: '. $_POST . '<br>'; $d=("$to");if ($d==" chris @chrisemail.co.za") $d="Chris";elseif($d==" danny @dannyemail.co.za ")$d="Danny";else $d="John";mail ($mailuser, 'Email from website - To ( '.$d.' )', $mail_body, $header);} else {// *** The input text did not match the stored text, so they failed ***// *** You would probably not want to include the correct answer, but// unless someone is trying on purpose to circumvent you specifically,// its not a big deal. If someone is trying to circumvent you, then// you should probably use a more secure way besides storing the// info in a cookie that always has the same name! :) ***echo "Sorry, you did not enter the correct code! Please return to the previous page to try again.<br><br>";}?>Now the form works everyone gets there email but for one or other reason Chris gets John’s emails also not all the time but he gets how can we sort this out any suggestions will help me a lotP.S John gets a copy of all the emails send thru to everyone else Thanks in advance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...