Jump to content

Email address change with ID


timmah1

Recommended Posts

I'm trying to have one contact form for every aspect of the site, but I need the form to go to different people depending on the id that is passed.

The subject works find with a variable being passed, but the $to part don't.

 

Here is what I'm 'trying'

if($_POST['id'] == "NN"){
$to='[email protected]';
$subject = '$_POST[subject]'; 
$headers = "From: Autisim Summer Camp Information\r\nX-Mailer: Autisim Summer Camp"; 
$body = "$_POST[first] $_POST[last] from $_POST[email] is requesting information about $_POST[subject].
In addition, they have posted this message: 
$_POST[message]"; 
mail($to, $subject, $body, $headers); 
}

else if($_POST['id'] == "NI"){
$to='[email protected]';
$subject = '$_POST[subject]'; 
$headers = "From: Autisim Summer Camp Information\r\nX-Mailer: Autisim Summer Camp"; 
$body = "$_POST[first] $_POST[last] from $_POST[email] is requesting information about $_POST[subject].
In addition, they have posted this message: 
$_POST[message]"; 
mail($to, $subject, $body, $headers); 
}

 

This doesn't work. Can anybody help me out?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/101131-email-address-change-with-id/
Share on other sites

What doesn't work about it?  Is there an error generated?  If so, what is it?  Have you tried troubleshooting?  What have you done to troubleshoot?  Have you verified the value of $_POST['id']?  Why are you duplicating all of the code in two places?  Employ the DRY method (http://en.wikipedia.org/wiki/DRY) to simplify.

 

if($_POST['id'] == "NN") {
$to='[email protected]';
} else if($_POST['id'] == "NI") {
$to='[email protected]';
}

echo "This message will be sent to " . $to . " because id is equal to " . $_POST['id'];

$subject = $_POST[subject]; 
$headers = "From: Autisim Summer Camp Information\r\nX-Mailer: Autisim Summer Camp"; 
$body = "$_POST[first] $_POST[last] from $_POST[email] is requesting information about $_POST[subject].
In addition, they have posted this message: 
$_POST[message]"; 
mail($to, $subject, $body, $headers); 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.