fiorano Posted September 25, 2009 Share Posted September 25, 2009 Hi, I have the following code for a contact form : <? $destination="[email protected]"; $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 Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/ 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="[email protected]"; } else if ($_POST['RadioGroup'] == 'clap' || $_POST['RadioGroup'] == 'put') { $destination = '[email protected]'; } The || operator means 'or'. Your radio buttons on your form should have name="RadioGroup" in their attributes as well. Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/#findComment-924650 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="[email protected]"; } else if ($_POST['RadioGroup'] == 'clap' || $_POST['RadioGroup'] == 'put') { $destination = '[email protected]'; } $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 Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/#findComment-924667 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. Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/#findComment-924673 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 Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/#findComment-924711 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,'[email protected]'); Replace [email protected] with your own from address, leaving the -f part in front of it as in the example. Link to comment https://forums.phpfreaks.com/topic/175474-php-mail-help/#findComment-924717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.