Hi there,
I have this code that I put together that has worked for years on numerous php servers. I tried to implement it on a go daddy server and it wont work.:mad:
They'll have it on php 4.9 I'm not sure what other settings or variables might be the issue. All I know is this is the first time the code didn't work on a php server.
Any help will be appreciated.
The script runs and gives errors fine along with the go back link to correct them. But when it runs through to the end and says Thank you like it does when it sends, no email arrives.
So here is the code:
<?php
if (isset($POST["op"]) && ($POST["op"]=="send")) {
/***** START OF CONFIG SECTION */
$sendto = "lar@works.com";
$subject = "Website Contact Enquiry";
// Select if you want to check form for standard spam text
$SpamCheck = "Y"; // Y or N
$SpamReplaceText = "content removed";
// Error message prited if spam form attack found
$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.
</font><br><b>Your IP Number of <b>".getenv("REMOTE_ADDR")."</b> has been logged.</b></p>";
/** END OF CONFIG SECTION ****/
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$company = $HTTP_POST_VARS['company'];
$address = $HTTP_POST_VARS['address'];
$telephone = $HTTP_POST_VARS['telephone'];
$fax = $HTTP_POST_VARS['fax'];
$sqft = $HTTP_POST_VARS['sqft'];
$message = $HTTP_POST_VARS['message'];
$place = $HTTP_POST_VARS['place'];
$headers = "From: $email\n";
$headers . "MIME-Version: 1.0\n"
. "Content-Transfer-Encoding: 7bit\n"
. "Content-type: text/html; charset = \"iso-8859-1\";\n\n";
if ($SpamCheck == "Y") {
// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = '/(;|||`|>|<|&||"|'."\n|\r|'".'|{|}|[|]|)|()/i'; // build the pattern match string
$name = preg_replace($pattern, "", $name);
$email = preg_replace($pattern, "", $email);
$message = preg_replace($pattern, "", $message);
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = array("/bcc:/i","/Content-Type:/i","/cc:/i","/to:/i");
$email = preg_replace($find, "$SpamReplaceText", $email);
$name = preg_replace($find, "$SpamReplaceText", $name);
$message = preg_replace($find, "$SpamReplaceText", $message);
// Check to see if the fields contain any content we want to ban
if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
// Do a check on the send email and subject text
if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
}
// Build the email body text
$emailcontent = "
WEBSITE CONTACT ENQUIRY
Name: $name
Email: $email
Company: $company
Address: $address
Telephone: $telephone
Fax: $fax
Sqft: $sqft
Message: $message
Place: $place
Attn: $attn
End of Email
";
// Check the email address enmtered matches the standard email address format
if (!eregi("[A-Z0-9.%-]+@[A-Z0-9.%-]+.[A-Z]{2,6}$", $email)) {
echo "<p>It appears you entered an invalid email address</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
elseif (!trim($name)) {
echo "<p>Please go back and enter a Name</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
elseif (!trim($message)) {
echo "<p>Please go back and type a Message</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
elseif (!trim($email)) {
echo "<p>Please go back and enter an Email</p><p><a href='javascript: history.go(-1)'>Click here to go back</a>.</p>";
}
// Sends out the email or will output the error message
elseif (mail($sendto, $subject, $emailcontent, $headers)) {
echo "<br><br><p><b>Thank You $name</b></p><p>We will be in touch as soon as possible.</p>";
}
}
else {
?>
<p align="center"> </p>
<br>
<form method="post"><INPUT NAME="op" TYPE="hidden" VALUE="send">
Name:<br /> <input name="name" size="35"
type="text" /> <br />
Email:<br /> <input name="email" size="35"
type="text" /> <br />
Company:<br />
<input name="company" size="35"
type="text" /> <br />
Address:<br />
<input name="address" size="35"
type="text" /> <br />
Telephone:<br />
<input name="telephone" size="35"
type="text" /> <br />
Fax:<br />
<input name="fax" size="35"
type="text" /> <br />
What place needs Service?<br />
<select name="place" size="1">
<option value="Choose">Choose</option>
<option value=" Church ">Church
</option>
<option value=" Health Care/Lab ">Health
Care/Lab </option>
<option value=" Industrial ">Industrial
</option>
<option value=" Office ">Office
</option>
<option value=" Restaurant ">Restaurant
</option>
<option value=" Retail ">Retail
</option>
<option value=" School ">School
</option>
<option value=" Shopping Center ">Shopping
Center </option>
<option value=" Other ">Other
</option>
</select><br>
When is service needed?<br />
<select name="attn" size="1">
<option value=" Choose">Choose</option>
<option value=" As soon as possible ">As
soon as possible</option>
<option value=" Within one week ">Within
one week </option>
<option value=" Within four weeks ">Within
four weeks </option>
<option value=" Beyond six weeks ">Beyond
six weeks </option>
</select>
<br />
<br>
Total Square Footage:<br />
<input name="sqft" size="35"
type="text" /> <br />
<tr>
<td valign="top"><p>Message:</p></td>
<td><textarea name="message" cols="40" rows="6"></textarea></td>
</tr>
</tr>
<tr><td></td> <td><input name="submit" type="submit" value="Submit"> <input name="reset" value="Reset"
type="reset" /></td></tr>
</table>
</form>
<?php } ?>