fiorano Posted September 25, 2009 Share Posted September 25, 2009 Hi, I have the following code for a contact form : <? $destination="sarah@here.com"; $name=$_POST['name']; $phone=$_POST['phone']; $email=$_POST['email']; $from = $_POST['email']; $mes=$_POST['message']; $header="From: $from\n"; $mes="Name: $name\n Phone: $phone\n Email: $email\n Message: $mes\n"; mail($destination,"Web Enquiry",$mes,$header); header( "Location: http://www.here.com/new_about.html" ); ?> Ive added four radio buttons the the form (radiogroup1) who's IDs are: id=RadioGroup1_0 val="ken" id=RadioGroup1_1 val="chis" id=RadioGroup1_2 val="clap" id=RadioGroup1_3 val="put" what i would like to do is if the first two radio buttons are clicked then send the enquiry to a certain email address, if the second two radio buttons are clicked then send it to a different email address. Can this be done. Any help greatly appreciated. Fiorano Quote Link to comment Share on other sites More sharing options...
bothwell Posted September 25, 2009 Share Posted September 25, 2009 Change your first line to: if($_POST['RadioGroup'] == 'ken' || $_POST['RadioGroup'] == 'chris') { $destination="sarah@here.com"; } else if ($_POST['RadioGroup'] == 'clap' || $_POST['RadioGroup'] == 'put') { $destination = 'somewhere@else.com'; } The || operator means 'or'. Your radio buttons on your form should have name="RadioGroup" in their attributes as well. Quote Link to comment Share on other sites More sharing options...
fiorano Posted September 25, 2009 Author Share Posted September 25, 2009 Hi Many thanks for your reply!! Ive changed my code to : <? if($_POST['RadioGroup'] == 'ken' || $_POST['RadioGroup'] == 'chris') { $destination="sarah@here.com"; } else if ($_POST['RadioGroup'] == 'clap' || $_POST['RadioGroup'] == 'put') { $destination = 'sofia@here.com'; } $name=$_POST['name']; $phone=$_POST['phone']; $email=$_POST['email']; $from = $_POST['email']; $mes=$_POST['message']; $header="From: $from\n"; $mes="Name: $name\n Phone: $phone\n Email: $email\n Message: $mes\n"; mail($destination,"Web Enquiry",$mes,$header); header( "Location: http://www.here.com/new_about.html" ); ?> its passing back to the http://www.here.com/new_about.html page but im not getting the email. Any more ideas?? Really appreciate your help. Fiorano Quote Link to comment Share on other sites More sharing options...
herghost Posted September 25, 2009 Share Posted September 25, 2009 Check that your host allows this, most hosts now will only allow smtp mail to cut down on spam. Quote Link to comment Share on other sites More sharing options...
fiorano Posted September 25, 2009 Author Share Posted September 25, 2009 Hi, Ive had the following response from my hosting company: This issue is occuring because there is a missing fifth parameter in your mail script. This has always been a requirement of mail scripts on our shared hosting platform but recent updates to our Linux servers (from PHP4 to PHP5) has meant that this is now always required. An example of how to use can be found at:http://www.streamlinesupport.net/index.php?page=show&id=149 http://www.streamlinesupport.net/index.php?page=show&id=149 Id really appreciate it if you could take at the link they supplies and offer any advice. Many, many thanks again! Fiorano Quote Link to comment Share on other sites More sharing options...
bothwell Posted September 25, 2009 Share Posted September 25, 2009 Your mail sending line should read: mail($destination,"Web Enquiry",$mes,$header,'-fyou@yourdomain.com'); Replace you@yourdomain.com with your own from address, leaving the -f part in front of it as in the example. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.