ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

PHP peoples... help pleeease :)



  306 TD Slut
I use a basic php contact form in most of my websites, which collects the data entered into several form fields and then sends it to a single email address.

I have been looking for a contact form where the user can select which receipient the data goes too.

So a drop down box with 3 names in so the user can select who to contact.

Does anyone have an php for this? or can i adapt the one i use already

Code:
<?php
// Website Contact Form Generator 
// [URL]http://www.tele-pro.co.uk/scripts/contact_form/[/URL] 
// This script is free to use as long as you 
// retain the credit link 
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "[EMAIL="mark.simons@yahoo.co.uk"]mark.simons@yahoo.co.uk[/EMAIL]";
$Subject = "MESSAGE FROM SAM WEBSITE";
$Name = Trim(stripslashes($_POST['Name'])); 
$Telephone = Trim(stripslashes($_POST['Telephone']));
$MessageSubject = Trim(stripslashes($_POST['MessageSubject'])); 
$Enquiry = Trim(stripslashes($_POST['Enquiry'])); 
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (empty($Name)) $validationOK=false;
if (empty($Telephone)) $validationOK=false;
if (empty($MessageSubject)) $validationOK=false;
if (empty($Enquiry)) $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "Regarding: ";
$Body .= $MessageSubject;
$Body .= "\n";
$Body .= "Enquiry: ";
$Body .= $Enquiry;
$Body .= "\n";
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page 
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

Dont want anything too complex im sure there is a simple bit of code i can add?

thanks in advance,
 
Drop down:
Code:
<select name="emailTo">
<option value="1">To 1st</option>
<option value="2">To 2nd</option>
<option value="3">To 3rd</option>
</select>
In php page, replace $EmailTo = "mark.simons@yahoo.co.uk"; with
PHP:
switch ($_POST['emailTo']){
  case '1':
  $EmailTo = "mark.simons@yahoo.co.uk";
  break;
  
  case '2':
  $EmailTo = "Second Email";
  break;
  
  case '3':
  $EmailTo = "Third Email";
  break;
}
 

KDF

  Audi TT Stronic
Drop down:
Code:
<select name="emailTo">
<option value="1">To 1st</option>
<option value="2">To 2nd</option>
<option value="3">To 3rd</option>
</select>
In php page, replace $EmailTo = "mark.simons@yahoo.co.uk"; with
PHP:
switch ($_POST['emailTo']){
  case '1':
  $EmailTo = "mark.simons@yahoo.co.uk";
  break;
  
  case '2':
  $EmailTo = "Second Email";
  break;
  
  case '3':
  $EmailTo = "Third Email";
  break;
}

easier method.

Code:
<select name="emailTo">
<option value="email1@address.com">To 1st</option>
<option value="email2@address.com">To 2nd</option>
<option value="email3@address.com">To 3rd</option>
</select>


Code:
$EmailTo = $_POST['emailTo'];
 


Top