Jump to content

[SOLVED] form mail with drop-down multiple emails.. why does it send doubles to option 2?


freaksilver

Recommended Posts

Hi there!

 

Really new to php.. I just tried to hash out this script through a few tutorials and some internet research..

 

It's a form to email script with a drop down box at the top so the user can choose which department to email. It seems to be working except for some reason when I send to "Graphics", it sends twice. The other three choices appear to be working properly.

 

Here is the html:

<table id="table" border="0" cellspacing="5"><form method="post" action="sendmail.php">
  <tr><td width="140" valign="top">Department:</td> <td align="left" valign="top">
    <select name="department" size="1">
     <option value="general">General</option>
  	 <option value="graphics">Graphics</option>
  	 <option value="sonics">Sonics</option>
     <option value="bookings">Booking</option>
</select> </td></tr>
  <tr><td width="140" valign="top">Your Name:</td> <td align="left" valign="top"><input name="name" type="text" size="50" /></td></tr>
  <tr><td width="140" valign="top">Reply Email:</td> <td align="left" valign="top"><input name="email" type="text" size="50" /></td></tr>
  <tr><td width="140" valign="top">Message:</td> <td align="left" valign="top"><textarea name="message" rows="7" cols="60"></textarea></td></tr>
  <tr><td width="140"></td><td valign="top"><input type="submit" value="Send Email" /></td></tr></form></table>

 

and here is the corresponding php

<?php
  $department = $_REQUEST['department'] ;
  $email = $_REQUEST['email'] ;
  $name = $_REQUEST['name'] ;
  $message = $_REQUEST['message'] ;
  
  $mailbody.="From: $name\n\n";
  $mailbody.="Email: $email\n\n";
  $mailbody.="Message: $message\n";
  
  if($department == 'general')
{
$sendto = "[email protected]";
}elseif($department == 'graphics'){
$sendto = "[email protected]";
}elseif($department == 'sonics'){
$sendto = "[email protected]";
}elseif($department == 'booking'){
$sendto = "[email protected]";
}; 

  if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: http://www.embryomedia.ca/contact.html" );
};

if (!isset($_REQUEST['email'])) {
    header( "Location: http://embryomedia.ca/contact.html" );
  }
  elseif (empty($email) || empty($message)) {
    header( "Location: http://embryomedia.ca/contacterror.html" );
  }
  else {
  mail( "$sendto", "Email from embryomedia.ca Contact Form",
    stripslashes($mailbody), "From: $email" );
  header( "Location: http://www.embryomedia.ca/thankyou.html" );
  }
?>

 

Any help would be greatly appreciated!! Thanks in advance..

 

Celeste

I don't see anything in your code that would send the message two times.  Are you sure the code itself is sending twice and that the recipients email address does not have some type of forwarder or something?

 

 

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.