Need some help integrating a mathematical question into a contact form

Hello all,

I can’t seem to get this to work…maybe I’m not doing it right, but I’m trying to integrate this mathematical question into my contact form as an anti-spam measure, but it doesn’t seem to want to display on the actual page.

would someone please tell me what I’m doing wrong or tweak the code to get the questions to actually show up on the form. I’d very much appreciate it.


<?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">Gallery</a></li>
<li><a href="http://www.pazrt.com/forum/forum-zrt-wiki">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="share-the-pennsylvania-zombie-response-team">Share</a></li>
<li><a href="http://www.cafepress.com/pazrt">Store</a></li>
</ul>
<!-- End Support drop-down menu -->
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li><!-- End support -->
<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 Social drop-down menu -->
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li><!-- End social -->
<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 id="contactpazrt" enctype="multipart/form-data" action="form.php" method="post" onsubmit="return validate_fields(this)">
<div style="display: none;">
<!-- Start Fake Form -->
<ul>
<li>Name:<br />
<input type="text" size="30" name="name" id="name" /></li>
<li><br /></li>
<li>Email:<br />
<input type="text" size="30" name="email" id="email" /></li>
<li><br /></li>
<li>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:<br />
<textarea name="comments" id="comments" rows="5" cols="45"></textarea></li>
</ul>
</div>
<!-- End Fake Form -->
<ul>
<li>Name:<?php echo $yourname; ?><br />
<input type="text" size="30" name="name1" id="name1" /></li>
<li><br /></li>
<li>Email:<?php echo $email; ?><br />
<input type="text" size="30" name="email1" id="email1" /></li>
<li><br /></li>
<li>Problem:<?php echo $problem; ?><br />
<select name="problem1">
<option value="website problem">Website Problem</option>
<option value="forum problem">Forum Problem</option>
<option value="misc problem">Miscellaneous</option>
</select></li>
<li><br /></li>
<li>Comments:<?php echo $comments; ?><br />
<textarea name="comments1" id="comments1" rows="3" cols="45"></textarea></li>
<li><br /></li>
<li>
<?php
$security_questions = array(
'1' => array('2 x 10 = ', '20'),
'2' => array('15 - 5 = ', '10'),
'3' => array('6 + 11 = ', '17'),
'4' => array('1 + 1 + 1 = ', '3'),
'5' => array('27 + 3 = ', '30'),
'6' => array('3 x 3 = ', '9'),
'7' => array('5 x 5 = ', '25'),
'8' => array('25 - 25 = ', '0'),
'9' => array('3 + 2 = ', '5'),
'10' => array('4 x 2 = ', '8'),
'11' => array('16 + 4 + 2 = ', '22'),
'12' => array('22 &#247; 2 = ', '11'),
'13' => array('4 &#247; 4 = ', '1'),
'14' => array('13 + 6 = ', '19'),
'15' => array('10 &#247; 2 = ', '5'),
'16' => array('100 + 100 = ', '200'),
'17' => array('10 x 10 = ', '100'),
'18' => array('30 - 22 = ', '8'),
'19' => array('6 &#247; 3 = ', '2'),
'20' => array('9 &#247; 3 = ', '3')
);

if ($_POST['sec_answer_n'] != $_SESSION['sec_answer'])	{
$error = true;
$sec_wrong = true;
}

$sec_rand = array_rand($security_questions);

$_SESSION['sec_answer'] = $security_questions[$sec_rand][1];


$inner .= ($error && strpos($errors['sec_answer_n'], 'Required Not Found') !== false) ? "<p style='color:red;'>Please enter the answer to the security question</p>\
" : ""; 
$inner .= ($sec_wrong) ? "<p style='color:red;'>You have answered the security question incorrectly</p>\
" : ""; 
$inner .= "<p>Security question: {$security_questions[$sec_rand][0]} &nbsp; <input type='text' size='10' name='sec_answer_n' /> answer </p>\
";
?>
</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" />
<p><a href="index.html">Home</a> | <a href="about-the-pennsylvania-zombie-response-team">About Us</a> | <a href="contact-the-pennsylvania-zombie-response-team">Contact Us</a><br /></p><p style="color: #FFF">Site by-<a href="http://www.webfinitydesign.com">Webfinity Design</a></p>
</div>
</div>
</body>
</html>

it doesn’t show up because you didn’t display it, try to echo the variable somewhere in your html form code


echo $inner;