Page 1 of 1

Email Script - test radio buttons

Posted: Fri Sep 11, 2009 3:56 am
by fiorano_2009
Hi,

I have the following code to send an email after a form submission:

Code: Select all

<?
$destination="website@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/thankyou.html" ); ?>
 
This is working fine.

Ive added four radio buttons to the form :
Rad1, Rad2,Rad3,Rad4
and depending on which buttons are selected I need to send the response to two different emails eg,

if Rad1 or Rad2 is selected then send the email to email1@here.com
else
if Rad3 or Rad4 is selected then send the email to email2@here.com

Is this possible??

Many thanks for any help,

Fiorano

Re: Email Script - test radio buttons

Posted: Fri Sep 11, 2009 5:23 am
by Weiry
well you would have to submit the data through post to itself ( $_SERVER['PHP_SELF'] )
but you could do it something like

Code: Select all

<input type='radio' value='1' name='radioSelect' /> Option 1
<input type='radio' value='1' name='radioSelect' /> Option 2
<input type='radio' value='2' name='radioSelect' /> Option 3
<input type='radio' value='2' name='radioSelect' /> Option 4
then when you want to check which email to send it to

Code: Select all

if($_POST['radioSelect']==1){
   // send to email 1
}elseif($_POST['radioSelect']==2){
   // send to email 2
}else{
   // give your error here
}