<?php
/* Form Mail for phpWebSite v1.1
----------------------------
Author: Edward Ritter (hide@address.com)
Based on PHPNuke FormMail by Paul Willard.
See README for functionality and changelog.
*/
if (!isset($mainfile)) { include ('mainfile.php'); }
include ('header.php');
$index = 0; //set to one to display right side boxes
/* The following is an array for the drop down box of
recipients. Please see the README for the format of
this variable. */
$maillist = array('Tech Support' => 'hide@address.com',
'Billing Dept' => 'hide@address.com,hide@address.com',
'Sales Dept' => 'hide@address.com',
'Webmaster' => 'hide@address.com',
'Postmaster' => 'hide@address.com',
'DNS Admin' => 'hide@address.com',
'Spam & Mail Abuse' => 'hide@address.com');
$boxtitle = ($recipient)?"Contact $recipient":"Contact Us";
/* This can be changed to whatever you want to say before the form is printed */
$boxstuff = "<p>So you need to contact us. Well, fill out this form
below and we'll be sure to get back to you.</p>";
if ($send == "ok") {
if (!$name || !$from || !$message) {
$err = "<span style=\"font-weight:bold;color:red\">»</span>";
$err_a = (!$name)?"$err":'';
$err_b = (!$from)?"$err":'';
$err_c = (!$message)?"$err":'';
$ok = "false";
}
if ($from != "") {
if (!eregi( "^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $from)) {
$err_b = "<span style=\"font-weight:bold;color:red\"> Invalid email address filled in.</span>";
$ok = "false";
}
}
if ($ok != "false") {
$message = stripslashes($message);
mail("$email", "$subject","$message\n\n---------\n
Came from host: $REMOTE_HOST\nIP Address: $REMOTE_ADDR",
"From: $name <$from>\nReply-To: $name <$from>\nSender: $name <$from>");
$boxstuff = "Thanks for contacting us, We'll respond as soon as we can.";
}
elseif ($ok == "false") { // prints out only if there is an error in the submission.
$boxstuff .= "<p>You left out some data. Please fill in the fields marked
with a <span style=\"font-weight:bold;color:red\">»</span></p>
<form method=\"post\" action=\"$PHP_SELF\">
<!-- recipient = $email -->
<input type=\"hidden\" name=\"email\" value=\"$email\" />
$err_a Your Name:<br />
<input type=\"text\" name=\"name\" size=\"30\" value=\"$name\" /><br />
$err_b Your Email Address:<br />
<input type=\"text\" name=\"from\" size=\"30\" value=\"$from\"><br />
$err_c What do you have to say? :<br />
<textarea rows=\"10\" name=\"message\" cols=\"60\">$message</textarea><br />
<input type=\"hidden\" name=\"send\" value=\"ok\" />
<input type=\"submit\" value=\"Send\" />
<input type=\"reset\" value=\"Empty fields\" /></form>";
}
} else { //default form that prints out.
$boxstuff .= "<form method=\"post\" action=\"$PHP_SELF\">
<!-- recipient = $recipient -->
Your Name: <br/><input type=\"text\" name=\"name\" size=\"30\"/><br />
Your Email Address: <br/><input type=\"text\" name=\"from\" size=\"30\"/><br /><br />";
if ($recipient == "") {
$boxstuff .= "I want to talk to :
<select name=\"email\">";
while ( list ($label, $addr) = each($maillist)) {
$boxstuff .= "<option value=\"$addr\">$label</option>\n";
}
$boxstuff .= "</select><br/><br/>";
} else {
$boxstuff .= "<input type=\"hidden\" name=\"email\" value=\"$recipient\">";
}
if ($subject == "") {
$boxstuff .= "Regarding : <br/><input type=\"text\" name=\"subject\" size=\"30\"><br />";
} else {
$boxstuff .= " <input type=\"hidden\" name=\"subject\" value=\"$subject\">";
}
$boxstuff .= "
What do you have to say? : <br/>
<textarea rows=\"10\" name=\"message\" cols=\"60\"></textarea><br />
<input type=\"hidden\" name=\"send\" value=\"ok\" />
<input type=\"submit\" value=\"Send\" />
<input type=\"reset\" value=\"Empty fields\" /></form>";
}
thememainbox($boxtitle,$boxstuff);
include('footer.php');
?>