Jump to content

PHP form HELP!!!


dminadeo

Recommended Posts

i'm begging anyone to help me... i can't get this to work for the life of me.

 

everytime i submit the form i get an error telling me to  input my $valid_ref1&2 domain names, but i do to what they tell me and i keep getting the same error. it's very frustrating.

 

here's the php code:

<?php

// ------- three variables you MUST change below  -------------------------------------------------------
$replyemail="[email protected]"; //change to your email address
$valid_ref1="http://viridianecosolutions.com/Thermapure/thermapure-form.html"; 
$valid_ref2="http://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 = false)
{
$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"];
$cityzip = $_POST["cityzip"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$structuretype = $_POST["structuretype"];
$besttime = $_POST["besttime"];
$pest = $_POST["pest"];
$length = $_POST["length"];
$width = $_POST["width"];
$additional = $_POST["additional"];

$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
$structuretype
$additionalinfo
--------------------------------------------------

Thank you";

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

Address: $address 

City/Zip: $city_zip 

Phone: $phone 

Email: $email

Structure type: $structuretype

Best time to call: $besttime

Pest type: $pest

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

Additional Info: $additional",

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

?>

 

and here's the form code in the html doc:

<form name="phpformmailer" action="contact_process.php" method="post">

<table width="580" border="0" cellpadding="0" cellspacing="0" class="form">
  <tr align="left" valign="middle">
    <td width="71">Name</td>
    <td width="226"><input name="name" type="text" class="formfield" id="name" /></td>
    <td>Best Time to Call
      <input name="besttime" type="text" class="formfield" id="besttime" style="width:80px" /></td>
    </tr>
  <tr>
    <td align="left" valign="middle">Address</td>
    <td align="left" valign="middle"><input name="address" type="text" class="formfield" id="address" /></td>
    <td rowspan="2" valign="bottom">What kind of pest are you having trouble with?<br />
      <select name="pest" id="pest" style="margin-top:5px">
        <option selected="selected">Choose</option>
        <option>Bed Bugs</option>
        <option>Cockroaches</option>
        <option>Dust Mites</option>
        <option>Rodents</option>
        <option>Scorpions</option>
        <option>Termites</option>
        <option>Other</option>
      </select></td>
    </tr>
  <tr align="left" valign="middle">
    <td>City/Zip</td>
    <td><input name="cityzip" type="text" class="formfield" id="cityzip" /></td>
    </tr>
  <tr>
    <td align="left" valign="middle">Phone</td>
    <td align="left" valign="middle"><input name="phone" type="text" class="formfield" id="phone" /></td>
    <td rowspan="2" valign="bottom">Square footage of the infested area
    <br />
      <input name="length" type="text" class="formfield" id="length" style="width:35px; margin-top:8px"/>
      L x
      <input name="width" type="text" class="formfield" id="width" style="width:35px; margin-top:8px"/>
      W</td>
    </tr>
  <tr align="left" valign="middle">
    <td>Email</td>
    <td><input name="email" type="text" class="formfield" id="email" /></td>
    </tr>
  <tr>
    <td colspan="2" align="left" valign="middle" style="padding-top:20px">Type of Structure</td>
    <td style="padding-top:20px;">Additional
details you feel are important</td>
    </tr>
  <tr>
    <td colspan="2" align="left" valign="top" style="padding-top:0px;padding-left:0px"><table width="250" border="0" align="left" cellpadding="0" cellspacing="0" class="checkbox">
      <tr id="checkbox">
        <td width="130" align="left" valign="top"><label>
          <input name="structure" type="checkbox" class="checkbox" id="structure_type_0" value="checkbox" />
          Home<br /></label>
<input type="checkbox" name="structure_type_4" value="checkbox" id="structure_type_1" />
            Condo<br />
<input type="checkbox" name="structure_type_3" value="checkbox" id="structure_type_2" />
              Apartment</td>
        <td width="120" align="left" valign="top"><input type="checkbox" name="structure_type_" value="checkbox" id="structure_type_3" />
          Hotel/B&B<br />
<input type="checkbox" name="structure_type_2" value="checkbox" id="structure_type_4" />
            Restaurant</td>
      </tr>
      </table></td>
    <td valign="top" ><textarea name="additional" cols="35" rows="10" class="formfield_multiline" id="additional"></textarea></td>
  </tr>
  </table><input type="image" src="images/submit_btn.png" alt="Submit" name="submit" width="117" height="36" align="left" id="Image2" style="padding-top:20px;" onmouseover="MM_swapImage('Image2','','images/submit_btn_rlv.png',1)" onmouseout="MM_swapImgRestore()" onclick="thermapure-thankyou.html" /></form>

 

thank you so much in advance.

 

 

 

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

$valid_ref1 and 2 have identical URL's, so try changing those.

 

Also, you have a double ';;' at the end of this:

<?php
$valid_ref2="http://viridianecosolutions.com/Thermapure/thermapure-form.html";;
?>

 

So change it to this:

 

<?php
$valid_ref2="http://viridianecosolutions.com/Thermapure/thermapure-form.html";
?>

And see if that helps.

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

the double ;; had no effect, that was a stupid mistake in making sure those were the exact ones from the error message.

 

any other thoughts?

 

BTW that fix has been changed and uploaded to the http://viridianecosolutions.com/Thermapure/thermapure-form.html form

 

 

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

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://viridianecosolutions.com/Thermapure/thermapure-form.html"; 
$valid_ref2="http://viridianecosolutions.com/Thermapure/thermapure-form.html"; 
Copy and paste the two lines above into the file: contact_process.php 
(replacing the existing variables and settings)

It looks like you've already done the above.

I'll try looking at the forms this time.

 

EDIT: the '12' means you need atleast 12 characters in the information form that needs to be filled in or something.

 

Looks like it's been fixed though.

Link to comment
https://forums.phpfreaks.com/topic/182824-php-form-help/#findComment-964991
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.