I am trying to have a "Contact us" page with a drop down tab that you can select from 4 people to contact. I am trying to figure out how to link each one to a certin email address. I was only able to get it with one. Thanks for your help.

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Email Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
<style type="text/css">
<!--
.style1 {
	font-size: 36px
}
.style2 {
	font-size: 36px;
	font-weight: bold;
}
.style4 {font-size: 14px}
.style7 {color: #99CCFF}
.style8 {font-size: 24px}
.style9 {
	color: #99CCFF;
	font-size: 16px;
	font-weight: bold;
}
.style11 {font-size: 16px}
.style12 {color: #99CCFF; font-size: 16px; }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=" />
</head>
<body bgcolor="#14285f">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="02021e">
    <td colspan="4" rowspan="2" nowrap="nowrap"><img src="rgl logo2.jpg" alt="Header image" width="253" height="90" border="0" /></td>
    <td height="58" colspan="3" valign="bottom" nowrap="nowrap" class="style1" id="logo"> <div align="center" class="style2"> 
      <div align="left">
        <div align="center" class="style2">
          <div align="left" class="style8">Corporate Duty Cell</div>
        </div>
      </div>
    </div></td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr bgcolor="02021E">
    <td height="26" nowrap="nowrap" colspan="3" id="tagline" valign="top"> <div align="left"></div></td>
	<td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="8"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

   <tr>
    <td height="14" colspan="8">&nbsp;<br />	</td>
  </tr>
  <tr>
    <td width="167" valign="top" height="370">
	<table width="167" height="242" border="0" cellpadding="0" cellspacing="0" id="navigation">
        <tr>
          <td width="167" height="40"><a href="index.html">Home</a></td>
        </tr>
        <tr>
          <td width="167" height="40"><a href="Core_Capabilities2.html">Core Capabilities</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Projects.html">Projects</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Customers.html">Customers</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Test_Locations.html">Test Locations</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Photo_Archive.html">Photo Archive</a></td>
      </tr>
    </table>
	<div align="center"></div></td>
    <td width="1" bgcolor="#445DA0"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
    <td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="304" height="1" border="0" /><br />
      <table width="725" height="469" border="0" cellpadding="0" cellspacing="0">
        <tr>
        <td width="725" height="469" class="bodyText"><table border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="843" class="pageName">
              </p>
              <p>&nbsp; </p>
              <form method="post" action="sendeail.php">
                <!-- DO NOT change ANY of the php sections -->
                <?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
                <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
                <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
                <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
                Your Name: <br />
  <input type="text" name="visitor" size="35" />
  <br />
                Your Email:<br />
  <input type="text" name="visitormail" size="35" />
  <br />
  <br />
  <br />
                Attention:<br />
  <select name="attn" size="1">
     <option value=" Webmaster ">Webmaster </option>
  <!-- HERE ERICH <option value=" General Info ">General Info </option>
    <option value=" Technical Support ">Technical Support </option>
    <option value=" RGL Team ">RGL Team </option> END ERICH-->
  </select>
  <br />
  <br />
                Mail Message: <br />
  <textarea name="notes" rows="4" cols="40"></textarea>
  <br />

  <input type="submit" value="Send Mail" />
              </form>
            <p>&nbsp; </p></td>
          </tr>
          <tr>
            <td align="left" class="bodyText">&nbsp;</td>
          </tr>
        </table>
          <p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          
        </body>
</html>
&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p></td>
        </tr>
    </table>	</td>
    <td width="37"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    <td width="4" valign="top"><img src="mm_spacer.gif" alt="" width="1" height="10" border="0" /><br />
      <br /> </td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="167">&nbsp;</td>
    <td width="1"></td>
    <td width="50">&nbsp;</td>
    <td width="182">&nbsp;</td>
    <td width="537">&nbsp;</td>
    <td width="37">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="center"><div align="left"><strong> 2008 Rgl-e.com</strong></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
<!-- Reminder: Change 'YourEmail' to Your real email --> 

<?php

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes'];
$attn = $_POST['attn'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! "); 
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ; 
$subject = $attn; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("erich.krauz@rgl-e.com", $subject, $message, $from);


?>

<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br />
  Attention: <?php echo $attn ?>
  <br />
  Message:<br /> 
  <?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
  <br />
  <?php echo $ip ?> 
  
  <br />
  <br />
  <a href="index.html"> Return to main page </a></p>
<p align="center">&nbsp;</p>
<p align="center">Someone will be contacting you shortly.</p>
</body>
</html>

</body>
</html>

You will need to take the POST value for the drop-down and use that as the E-Mail to address in the mail function, preferably, use names without an @ or domain.com and use PHP to assign an email:

switch($_POST['attn']) {
case name1:
$to_email = "name1@domain.com";
break;
case name2:
$to_email = "name2@domain.com";
break;
default:
$to_email = "Address if email not selected";
}

Don't put the E-Mail address in the field on the form as this can be edited client-side and may compromise your script.

Hey, Thanks for the tips. I am trying to learn this for fun. I thought it would of been a little easier...lol Here is what I am trying to do now after your help... I am still not able to get it to send emails after clicking webmaster or general info. Any advice?
$from = "From: $visitormail\r\n";
switch($_POST) {
case Webmaster:$to_email = mail("erich.krauz@rgl-e.com", $subject, $message, $from);
break;
case General Info:$to_email = mail("krauz2@hotmail.com", $subject, $message, $from);
break;
default:$to_email = "krauz2@hotmail.com";}

In contact1.php, change the 'value' for each of the <option> tags in the select to a single word in lower case to make it easire, for example, webmaster, info, tech and rgl like so:

<select name="attn" size="1">
<option value="webmaster">Webmaster </option>
 <option value="info">General Info </option>
</select>

Then in the other file put:

switch($_POST['attn']) {
case Webmaster:
$to_email = "erich.krauz@rgl-e.com";
break;
case info:
$to_email = "krauz2@hotmail.com";
break;
default:
$to_email = "krauz2@hotmail.com";
}
mail($to_email, $subject, $message, $from);

It would also be a good idea to handle any errors thrown by the mail function like so:

@$send_email = mail($to_email, $subject, $message, $from);
if($send_email) {
echo "E-Mail sent successfully";
} else {
echo "The E-Mail was not sent.";
}

Thanks again, The email is getting sent reguardless of which option I pick. The only problem is, it keeps sending the defult email so i am guessing it is not seeing the first two options....?

Attention:<br />
<select name="attn" size="1">
<option value=" webmaster ">Webmaster </option>
<option value=" info ">General Info </option>

Are you in England? If so, you are up pretty late..lol I was stationed there a few months ago at RAF Lakenheath

Does the script in your last posts work? As this seems to be correct.

Make sure you put your code in code-tags so that it displays correctly

Also, yes I am based in the UK, but I work nightshift as tech support in the US department of a PC company

Edited 3 Years Ago by mike_2000_17: Fixed formatting

I bet it is something small..lol It sends emails but to the default email address. It does not even see the web and info. This is what I've added. Thanks again for helping me out.

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Email Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
<style type="text/css">
<!--
.style1 {
	font-size: 36px
}
.style2 {
	font-size: 36px;
	font-weight: bold;
}
.style4 {font-size: 14px}
.style7 {color: #99CCFF}
.style8 {font-size: 24px}
.style9 {
	color: #99CCFF;
	font-size: 16px;
	font-weight: bold;
}
.style11 {font-size: 16px}
.style12 {color: #99CCFF; font-size: 16px; }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=" />
</head>
<body bgcolor="#14285f">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="02021e">
    <td colspan="4" rowspan="2" nowrap="nowrap"><img src="rgl logo2.jpg" alt="Header image" width="253" height="90" border="0" /></td>
    <td height="58" colspan="3" valign="bottom" nowrap="nowrap" class="style1" id="logo"> <div align="center" class="style2"> 
      <div align="left">
        <div align="center" class="style2">
          <div align="left" class="style8">Corporate Duty Cell</div>
        </div>
      </div>
    </div></td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr bgcolor="02021E">
    <td height="26" nowrap="nowrap" colspan="3" id="tagline" valign="top"> <div align="left"></div></td>
	<td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="8"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

   <tr>
    <td height="14" colspan="8">&nbsp;<br />	</td>
  </tr>
  <tr>
    <td width="167" valign="top" height="370">
	<table width="167" height="242" border="0" cellpadding="0" cellspacing="0" id="navigation">
        <tr>
          <td width="167" height="40"><a href="index.html">Home</a></td>
        </tr>
        <tr>
          <td width="167" height="40"><a href="Core_Capabilities2.html">Core Capabilities</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Projects.html">Projects</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Customers.html">Customers</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Test_Locations.html">Test Locations</a></td>
      </tr>
        <tr>
          <td width="167" height="40"><a href="Photo_Archive.html">Photo Archive</a></td>
      </tr>
    </table>
	<div align="center"></div></td>
    <td width="1" bgcolor="#445DA0"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
    <td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="304" height="1" border="0" /><br />
      <table width="725" height="469" border="0" cellpadding="0" cellspacing="0">
        <tr>
        <td width="725" height="469" class="bodyText"><table border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="843" class="pageName">
              </p>
              <p>&nbsp; </p>
              <form method="post" action="sendeail.php">
                <!-- DO NOT change ANY of the php sections -->
                <?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
                <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
                <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
                <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
                Your Name: <br />
  <input type="text" name="visitor" size="35" />
  <br />
                Your Email:<br />
  <input type="text" name="visitormail" size="35" />
  <br />
  <br />
  <br />
                Attention:<br />
  <select name="attn" size="1">
     <option value=" webmaster ">Webmaster </option>
  <option value=" info ">General Info </option>
   
  </select>
  <br />
  <br />
                Mail Message: <br />
  <textarea name="notes" rows="4" cols="40"></textarea>
  <br />

  <input type="submit" value="Send Mail" />
              </form>
            <p>&nbsp; </p></td>
          </tr>
          <tr>
            <td align="left" class="bodyText">&nbsp;</td>
          </tr>
        </table>
          <p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          
        </body>
</html>
&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p></td>
        </tr>
    </table>	</td>
    <td width="37"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    <td width="4" valign="top"><img src="mm_spacer.gif" alt="" width="1" height="10" border="0" /><br />
      <br /> </td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="167">&nbsp;</td>
    <td width="1"></td>
    <td width="50">&nbsp;</td>
    <td width="182">&nbsp;</td>
    <td width="537">&nbsp;</td>
    <td width="37">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="center"><div align="left"><strong> 2008 Rgl-e.com</strong></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
<!-- Reminder: Change 'YourEmail' to Your real email --> 

<?php

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes'];
$attn = $_POST['attn'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! "); 
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ; 
$subject = $attn; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";

switch($_POST['attn']) {

case webmaster:$to_email = "erich.krauz@rgl-e.com";
break;
case info:$to_email = "krauz2@hotmail.com";
break;
default:
$to_email = "erich.krauz@rgl-e.com";
}
mail($to_email, $subject, $message, $from);



?>

<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br />
  Attention: <?php echo $attn ?>
  <br />
  Message:<br /> 
  <?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
  <br />
  <?php echo $ip ?> 
  
  <br />
  <br />
  <a href="index.html"> Return to main page </a></p>
<p align="center">&nbsp;</p>
<p align="center">Someone will be contacting you shortly.</p>
</body>
</html>

</body>
</html>

I think so...so like?
<select name = "attn" size = "1" >
<option value = "webmaster" > Webmaster </option>
<option value = "info" > General Info </option>

</select>

still nothin. What else do you think I can try besides a switch function?

What happens if you put the following into the PHP script:

echo $_POST['attn'];

wrap the switch and mail functions with /* and */ to prevent them running:

/*
switch($_POST['attn']) {

case webmaster:$to_email = "erich.krauz@rgl-e.com";
break;
case info:$to_email = "krauz2@hotmail.com";
break;
default:
$to_email = "erich.krauz@rgl-e.com";
}
mail($to_email, $subject, $message, $from);
*/
echo $_POST['attn'];

Also, I just noticed you previously had $attn = $_POST; so you would be able to replace $_POST with $attn in the switch statement.

It goes to my submitted page but does not send any emails

In the top left corner it shows info...(the option that was selected"

WheN i put it to webmaster it shows webmaster in the top left on my submitted page

does this look right?
switch($_POST) {

how else can I have it...I see it says $attn = $_POST

so would that mean...
switch[$attn]

My bad, put the values on the case statements in the switch in '':

switch($_POST['attn']) {
case 'webmaster':
$to_email = "erich.krauz@rgl-e.com";
break;
case 'info':
$to_email = "krauz2@hotmail.com";
break;
default:
$to_email = "erich.krauz@rgl-e.com";
}
mail($to_email, $subject, $message, $from);

You could also use switch($attn) {

It keeps goign to the defult email. I kept the echo in and it displays the correct choise in the upper left hand corrner. So it doesnt care which one i pick, it just sends it to default email. LOL whats going on with this

You could try using an IF rather than a switch:

if($attn == "webmaster") {
$to_email = "erich.krauz@rgl-e.com";
} elseif($attn == "info") {
$to_email = "krauz2@hotmail.com";
} else {
$to_email = "erich.krauz@rgl-e.com";
}

thanks for your help xan. I am going to mess around with it for a while and see what I can come up with. Thank you so much for all your help.

The variable $attn would only work if he has register_globals on, which is turned off by default in PHP => 4.3.0 since it is a security vulnerability.

krauz2, you can try something like:

$to_email = ($_POST['attn'] == "info") ? "krauz2@hotmail.com" : "erich.krauz@rgl-e.com";

Please check and make sure $_POST isn't empty:

if(empty($_POST['attn'])){die("Variable _POST['attn'] is empty for some reason.";} // demonstration purposes only.

No, check line 28 of his sendemail.php script:

$attn = $_POST['attn'];

Also, he has been echoing the attn value and it is printing the correct item.

Comments
sorry mate

Ah, sorry, didn't read the script at all, I admit. It now comes to my attention that the code I posted above is totally irrelevant.

thanks for all your help. I was able to get the switch to work. I tried the attn instead of the other way and for some reason it worked. I tell you its a pretty good feeling when you see it work...lol
Erich

This question has already been answered. Start a new discussion instead.