Jump to content

PHP form mailer help


dminadeo

Recommended Posts

i must be missing something here, i'm sure it's a stupid mistake on my part...

any help would be greatly appreciated

<?php

// ------- three variables you MUST change below  -------------------------------------------------------
$replyemail="[email protected]"; //change to your email address
$valid_ref1="http://pci-email.net/viridianecosolutions.com/Thermapure/thermapure-form.html"; 
$valid_ref2="http://pci-email.net/viridianecosolutions.com/Thermapure/thermapure-form.html";//chamge to your domain name
//chamge to your domain name

// -------- No changes required below here -------------------------------------------------------------
//
// email variable not set - load $valid_ref1 page
if (!isset($_POST['email']))
{
echo "<script language=\"JavaScript\"><!--\n ";
echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
exit;
}
$ref_page=$_SERVER["HTTP_REFERER"];
$valid_referrer=0;
if($ref_page==$valid_ref1) $valid_referrer=1;
elseif($ref_page==$valid_ref2) $valid_referrer=1;
if((!$valid_referrer) OR ($_POST["block_spam_bots"]!=12))
//you can change this but remember to change it in the contact form too
{
echo '<h2>ERROR - not sent.';

if (file_exists("debug.flag")) echo '<hr>"$valid_ref1" and "$valid_ref2" are incorrect within the file:<br>

                                      contact_process.php <br><br>On your system these should be set to: <blockquote>

								  $valid_ref1="'.str_replace("www.","",$ref_page).'"; <br>

								  $valid_ref2="'.$ref_page.'";

								  </blockquote></h2>Copy and paste the two lines above 

								  into the file: contact_process.php <br> (replacing the existing variables and settings)';
exit;
}

//check user input for possible header injection attempts!
function is_forbidden($str,$check_all_patterns = true)
{
$patterns[0] = 'content-type:';
$patterns[1] = 'mime-version';
$patterns[2] = 'multipart/mixed';
$patterns[3] = 'Content-Transfer-Encoding';
$patterns[4] = 'to:';
$patterns[5] = 'cc:';
$patterns[6] = 'bcc:';
$forbidden = 0;
for ($i=0; $i<count($patterns); $i++)
  {
   $forbidden = eregi($patterns[$i], strtolower($str));
   if ($forbidden) break;
  }
//check for line breaks if checking all patterns
if ($check_all_patterns AND !$forbidden) $forbidden = preg_match("/(%0a|%0d|\\n+|\\r+)/i", $str);
if ($forbidden)
{
  echo "<font color=red><center><h3>STOP! Message not sent.</font></h3><br><b>
        The text you entered is forbidden, it includes one or more of the following:
        <br><textarea rows=9 cols=25>";
  foreach ($patterns as $key => $value) echo $value."\n";
  echo "\\n\n\\r</textarea><br>Click back on your browser, remove the above characters and try again.
        </b>";
  exit();
}
}

foreach ($_REQUEST as $key => $value) //check all input 
{
if ($key == "request") is_forbidden($value, false); //check input except for line breaks
else is_forbidden($value);//check all
}

$name = $_POST["name"];
$address = $_POST["address"];
$city_zip = $_POST["city_zip"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$structure_type = $_POST["structure_type"];
$best_time = $_POST["best_time"];
$pest = $_POST["pest"];
$length = $_POST["length"];
$width = $_POST["width"];
$additional_info = $_POST["additional_info"];

$success_sent_msg='<p align="center"><strong>Thank You</strong></p>
                   <p align="center"><strong>Your order has been successfully sent to us<br>
                   </strong> and we will reply as soon as possible.</p>
                   <p align="center">A copy of your query has been sent to you.</p>
                   <p align="center">Thank you for contacting us.</p>';

$replymessage = "Hi $name

Thank you for your email.

We will respond to reply to you shortly.

Please DO NOT reply to this email.

Below is a copy of the message you submitted:
--------------------------------------------------
Subject: Thermapure Form Request
Query:
$pest
$structure_type
$additional_info
--------------------------------------------------

Thank you";

$request = "name: $name \nQuery: $additional_info";
mail("$replyemail",
     "Thermapure Heat Request Form",
"Name: $name 

Address: $address 

City/Zip: $city_zip 

Phone: $phone 

Email: $email

Structure type: $structure_type

Best time to call: $best_time

Pest type: $pest

Square footage: $length (L) x $width (W)

Additional Info: $additional_info",

 "From: $email");
mail("$email",
     "Receipt: Thermapure form request sent",
     "$replymessage",
     "From: $replyemail");
echo $success_sent_msg;

?>

 

Link to comment
https://forums.phpfreaks.com/topic/182702-php-form-mailer-help/
Share on other sites

sorry dude, my psychic powers are low today.  i'm not going to be able to guess the issue you're having, the error that's being displayed, and so on.  i apologize for this as i should have better intuition.

 

in the meantime, feel free to expand a bit on your end.  perhaps ask a question?  where i come from, if you want help in a timely fashion, you need to come prepared.

Link to comment
https://forums.phpfreaks.com/topic/182702-php-form-mailer-help/#findComment-964313
Share on other sites

I'm sorry i meant to include this in the post. when submitted i keep getting this:

ERROR - not sent.
"$valid_ref1" and "$valid_ref2" are incorrect within the file:
contact_process.php 

On your system these should be set to:
$valid_ref1="http://pci-email.net/viridianecosolutions.com/Thermapure/thermapure-form.html"; 
$valid_ref2="http://pci-email.net/viridianecosolutions.com/Thermapure/thermapure-form.html";

 

but i've already replaced those. i'm wondering if i have something wrong in this part:

$request = "name: $name \nQuery: $additional_info";
mail("$replyemail",
     "Thermapure Heat Request Form",
"Name: $name 

Address: $address 

City/Zip: $city_zip 

Phone: $phone 

Email: $email

Structure type: $structure_type

Best time to call: $best_time

Pest type: $pest

Square footage: $length (L) x $width (W)

Additional Info: $additional_info",

 "From: $email");

 

thanks again

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/182702-php-form-mailer-help/#findComment-964330
Share on other sites

There is only one place in your code which outputs that error message, which narrows things down.

 

if((!$valid_referrer) OR ($_POST["block_spam_bots"]!=12)) {
   echo '<h2>ERROR - not sent.';

So the only reason you will get the error is if either...

a.) $_SERVER["HTTP_REFERER"]; doesn't match $valid_ref1 or $valid_ref2.

b.) $_POST["block_spam_bots"] isn't equal to 12.

 

To check a.) echo out  $_SERVER["HTTP_REFERER"] and manually check why it doesn't match. To check b.) you can also echo it out, but just check your form has an HTML element with the attributes (name="block_spam_bots" value="12").

Link to comment
https://forums.phpfreaks.com/topic/182702-php-form-mailer-help/#findComment-965348
Share on other sites

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.