PDA

View Full Version : php anti-spam form help


andrewjs18
24th March 10, 06:16 AM
hello,

I had a friend of mine code me a php anti-spam for my form, but it's not working properly and he's went MIA. maybe someone here can help me.

basically, when submitting the form after entering the text for the captcha image it'll return this error:
There was an error: You must fill out all information correctly.

but still send the form....the captcha is entered correctly, too.

here's the link so you can try it out for yourself-
http://www.pazrt.com/contact-the-pennsylvania-zombie-response-team

here's the form page and php files-

contact.php

<?php

session_start();

require('include.php');
require('securimage/securimage.php');

$securimage = new Securimage();

if (isset($_POST['action']) && $_POST['action'] == 'Submit') {
if ($securimage->check($_POST['captcha_code']) != false && validEmail($_POST['email'])) {
$name = $_POST["name"];
$email = $_POST["email"];
$problem = $_POST["problem"];
$comments = $_POST["comments"];

$address_to = "andrewjs18@pazrt.com";
$address_from = "From: form@pazrt.com";
$email_subject_line = $name . "'s form";

$email_text = "Name? " . $name .
"\nEmail? " . $email .
"\nProblem? " . $problem .
"\nComments? " . $comments;

if (!@mail($address_to, $email_subject_line, $email_text, $address_from)) {
header("Location:thanks.html");
exit;
} else {
$error = "Couldn't send email, please try again later.";
}
} else {
$error = "You must fill out all information correctly.";
}
}

?>
<?php
$name = htmlspecialchars($_POST['yourname']);
$email = htmlspecialchars($_POST['email']);
$problem = htmlspecialchars($_POST['problem']);
$comments = htmlspecialchars($_POST['comments']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Contact the PAZRT- Pennsylvania Zombie Response Team</title>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Pennsylvania Zombie Response Team" />
<meta name="copyright" content='All Copyright Pennsylvania Zombie Response Team, all rights reserved' />
<meta name="description" content="PAZRT- Pennsylvania Zombie Response Team is an elite group of people dedicated to the preservation of the human race in the face of a looming zombie outbreak" />
<meta name="keywords" content="pazrt, zrt, pennsylvania zombie response team, pennsylvania zrt, zombies, zombie response team, guns, knives, survival" />
<link href="layout.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="validation.js"></script>
</head>
<body>
<!-- This is the main div -->
<div id="wrapper">
<!-- Start logo coding -->
<div id="logo">
<img src="images/logo.png" alt="main logo" height="168px" style="width: 100%" />
</div>
<!-- Start navigation bar coding -->
<div id="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about-the-pennsylvania-zombie-response-team">About Us</a></li>
<li><a href="http://www.pazrt.com/forum">Forums</a></li>
<li><a href="http://www.pazrt.com/gallery/main.php">Gallery</a></li>
<li><a href="http://wiki.pazrt.com">Wiki</a></li>
<li><a href="#">Support<!--[if gte IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<li><a href="donate-to-the-pennsylvania-zombie-response-team">Donate</a></li>
<li><a href="link-to-pennsylvania-zombie-response-team">Links</a></li>
<li><a href="http://www.cafepress.com/pazrt">Store</a></li>
</ul>
<!-- End Links drop-down menu -->
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
<li><a href="#">Social<!--[if gte IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<li><a href="http://www.twitter.com/pazrt">Twitter</a></li>
<li><a href="http://www.facebook.com/pages/Pennsylvania-Zombie-Response-Team/10150095905020602">Facebook</a></li>
<li><a href="http://www.youtube.com/pazrt">Youtube</a></li>
</ul>
<!-- End Links drop-down menu -->
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
<li class="selected"><a href="contact-the-pennsylvania-zombie-response-team">Contact Us</a></li>
</ul>
</div>
<!-- Start contact content coding -->
<div id="contact">
<img src="images/leftlogo.png" alt="left logo" width="440px" style="float: left" />
<form name="contact" enctype="multipart/form-data" action="contact.php" method="post" onsubmit="return validate_fields(this)">
<ul>
<?php if (isset($error)): ?><li>There was an error: <?php echo $error; ?></li>
<li><br /></li>
<?php endif; ?>
<li>Name:<?php echo $yourname; ?><br />
<input type="text" size="30" name="name" id="name" /></li>
<li><br /></li>
<li>Email:<?php echo $email; ?><br />
<input type="text" size="30" name="email" id="email" /></li>
<li><br /></li>
<li>Problem:<?php echo $problem; ?><br />
<select name="problem">
<option value="website">Website Problem</option>
<option value="forum">Forum Problem</option>
<option value="misc">Miscellaneous</option>
</select></li>
<li><br /></li>
<li>Comments:<?php echo $comments; ?><br />
<textarea name="comments" id="comments" rows="5" cols="45"></textarea></li>
<li><br /></li>
<li>
<input type="text" name="captcha_code" size="10" maxlength="6" />
<img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" />
<a href="javascript: //;" onclick="document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random(); return false">Reload Image</a>
</li>
<li><br /></li>
<li><input type="submit" name="action" value="Submit" />
&nbsp;
<input type="reset" name="reset" value="Reset" /></li>
</ul>
</form>

</div>
<!-- Start footer coding -->
<div id="footer">
<img src="images/footer.png" alt="footer logo" width="1000px" />
</div>
</div>
<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script>
<script type="text/javascript">try { var pageTracker = _gat._getTracker("UA-10934935-1"); pageTracker._trackPageview(); } catch(err) {}</script>
</body>
</html>

include.php (the include file is to large to post so I just put it into a .txt format so it can be viewed)
http://www.pazrt.com/include.php.txt

kcire
30th May 10, 02:19 PM
It seems to be working fine a minute ago...