Jump to content

Php Mail Help


fiorano

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.