Jump to content

HTML Email Form help please


deansp2001

Recommended Posts

Sorry - here it is - I did not write this code.

 

 

<?

$from_address = "[email protected]";
$required_on = "no";
$required_errorpage = "error.html";
$override = "no";
$incoming_mailto = "[email protected]";
$incoming_subject = "Dacon request Call";
$incoming_thanks = "requestcall2.php";
$ban_ip_on = "no";
$ban_ip_list = "111.222.33.55,11.33.777.99";
$secure_domain_on = "no";
$autorespond_on = "no";
$autorespond_subject = "Car Retail Solutions - Thank you";
$autorespond_from = "[email protected]";
$autorespond_contents = "Dear Sir/Madam

Thank you for reserving your place at the Car Retail Solutions seminar on the 2nd June 2007

If you need any more information please do not hesitate to contact us";

$autorespond_mailto_field = "Email";

if($_SERVER['REQUEST_METHOD'] == "GET") {
echo "
<html>
<head><title>Webligo PHP DynaForm is installed correctly.</title></head>
<body>
<font style='font-family: verdana, arial; font-size: 9pt;'>
<b>DynaForm is installed correctly.</b></font><br>
<font style='font-family: verdana, arial; font-size: 8pt;'>
DynaForm Easy PHP Form Mailer was created by <a href='http://www.webligo.com'>Webligo Developments</a>.
</font>
</body></html>
";
exit();
}


$incoming_fields = array_keys($_POST);
$incoming_values = array_values($_POST);

if($override == "no") {
$incoming_mailto = $_POST['rec_mailto'];
$incoming_subject = $_POST['rec_subject'];
$incoming_thanks = $_POST['rec_thanks'];
}

$incoming_mailto_cc = $_POST['opt_mailto_cc'];
$incoming_mailto_bcc = $_POST['opt_mailto_bcc'];
$form_url = $_POST[HTTP_REFERER];


if($secure_domain_on == "yes") {
$form_url_array = parse_url($form_url);
$form_domain = $form_url_array[host];
if($form_domain != $_SERVER[HTTP_HOST]) {
echo "<h2>DynaForm Error - Invalid Domain</h2>
You have accessed DynaForm from an external domain - this is not allowed.<br>
You may only submit forms to a DynaForm file that exists on the same domain name.<br>
If you believe to be receiving this message in error, please refer to your readme.txt file.
<br><br>";
$error = "yes";
}
}


if($incoming_mailto == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_mailto</b>\" field within the form. This field specifies who the email will
be sent to.
<br><br>
This should look like:<br>
&#060;input type=\"hidden\" name=\"rec_mailto\" value=\"[email protected]\"&#062;
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}


if($incoming_subject == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_subject</b>\" field within the form. This field specifies the subject of
the email that will be sent.
<br><br>
This should look like:<br>
&#060;input type=\"hidden\" name=\"rec_subject\" value=\"CRS Seminar 2nd June - Confirmation\"&#062;
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}


if($incoming_thanks == "") {
echo "<h2>DynaForm Error - Missing Field</h2>
Your form located at <a href='$form_url'>$form_url</a> does not work because you forgot to include
the required \"<b>rec_thanks</b>\" field within the form. This field specifies what page the user
will be taken to after they submit the form.
<br><br>
This should look like:<br>
&#060;input type=\"hidden\" name=\"rec_thanks\" value=\"thanks.html\"&#062;
<br><br>
If you are still confused, please refer to the readme.txt for more information and examples.<br><br><br><br>
";
$error = "yes";
}


if($ban_ip_on == "yes") {

if(strstr($ban_ip_list, $_SERVER[REMOTE_ADDR])) {
echo "<h2>DynaForm Error - Banned IP</h2>
You cannot use this form because your IP address has been banned by the administrator.<br>
";
$error = "yes";
}
}


if($error == "yes") {
exit();
}


$message = "Please call this customer ASAP \n\n";


for ($i = 0; $i < count($incoming_fields); $i++) { 
if($incoming_fields[$i] != "rec_mailto") {
if($incoming_fields[$i] != "rec_subject") {
if($incoming_fields[$i] != "rec_thanks") {
if($incoming_fields[$i] != "opt_mailto_cc") {
if($incoming_fields[$i] != "opt_mailto_bcc") {


if($required_on == "yes") {
$sub = substr($incoming_fields[$i], 0, 2);
if($sub == "r_") {
if($incoming_values[$i] == "" OR !isset($incoming_values[$i]) OR $incoming_values[$i] == " ") {
header("Location: $required_errorpage");
exit();
}}}

$message .= "$incoming_fields[$i]:\n$incoming_values[$i]\n\n";
}}}}}}



$headers = "";

if($from_address != "") {
$headers .= "From: $from_address\r\n";
}


if($incoming_mailto_cc != "") {
$headers .= "Cc: $incoming_mailto_cc\r\n";
}
if($incoming_mailto_bcc != "") {
$headers .= "Bcc: $incoming_mailto_bcc\r\n";
}


mail($incoming_mailto, $incoming_subject, $message, $headers);

if($autorespond_on == "yes") {
$autorespond_mailto = $_POST[$autorespond_mailto_field];
$autorespond_headers = "From: $autorespond_from";
mail($autorespond_mailto, $autorespond_subject, $autorespond_contents, $autorespond_headers);
}


header("Location: $incoming_thanks"); 


?>

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.