Okay, going through all of that was a bit 'jumbled' so I wrote a controller for you. I've pasted it below but I'm sure the spacing will be thrown off. If you want the actual file just send me an eMail I'll send it to you. You can just click my username and a drop-down list will come with a link to eMail me.
You will need to add a textfield to your contact form so the visitor can type in their name. The field name should be 'visitor'.
PHP Code:
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$ccopy = $_POST['ccopy'];
$attn = $_POST['attn'];
$notes = stripcslashes($_POST['notes']);
if(!$visitormail || !$notes || !$visitor) {
//if visitor, visitormail or notes fields were left blank
echo "<h1>Use Back: Please enter all information</h1> \n";
}
else {
//Decide where eMail should go
switch($attn) {
case 'Technical Support':
$mail_to = 'hi@hungryscafe.com';
break;
case 'General Support':
$mail_to = 'hi@hungryscafe.com';
break;
case 'Webmaster':
$mail_to = 'webmaster@hungryscafe.com';
break;
case 'Sales':
$mail_to = 'jcs@hungryscafe.com';
break;
default:
$mail_to = 'hi@hungryscafe.com';
break;
}
//Today's date
$todayis = date("l, F j, Y, g:i a") ;
//eMail Subject
$subject = $attn;
//eMail Message
$message = "
$todayis [EST]
Attention: $attn
Message: $notes
From: $visitor ($visitormail)
Additional Info:
IP: $ip
Browser: $httpagent
Referral: $httpref";
//eMail From
$from = "From: $visitor <$visitoremail>";
//Mail Form
if($ccopy) {
//If CCopy was selected add visitor email
$mail_to = "$mail_to, $visitormail";
$send_form = mail($mail_to, $subject, $message, $from);
}
else {
//ccopy was not selected
$send_form = mail($mail_to, $subject, $message, $from);
}
//If form was sent echo thank you message
if($send_form) {
?>
<p align="center"> <?php echo $todayis ?></p>
<p align="center"><br />
<strong>Thank you, <span class="style77"><?php echo $visitor ?> </span>for contacting our office. </strong><br />
<br />
<strong>Attention:</strong> <?php echo $attn ?></p>
<p align="center"><br />
<strong>Message:</strong><br />
<span class="style77">
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<?php
}
else {
echo "<p>We are sorry but there was a problem sending your information. Please try again.</p>";
}
}
?>
Bookmarks