Jump to content

Request Form with PHP Captcha script not working


Wolverine68

Recommended Posts

I created a request form with a CAPTCHA script (for filtering out spammers).  If the form is submitted without the correct string it is suppose to give an error message.  If the form is submitted with the correct string then it's suppose to give a thank you message along with the current time and date.

 

I've tested both scenarios but in both cases it just goes to a blank screen.  Here's the link to the form:

 

http://klb68.comxa.com/request_form11.html

 

 

HTML form code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php
session_start();
?>
<html>

<head>
<title>Request Form</title>
</head>

<body background="#EEEEEE">
<img src="pics\um-cross3.gif" height="100" width="100"><img src="pics\title.gif"><br>
<h3 align="center">Information Request Form</h3>
<div>
<form action="feedback11.php" method="post">

<p><font color="blue">Thank you for visiting our website. If you would like more information, please fill out all the information in the form below. When finished, click on the "Submit" button. Be sure to include your address, e-mail, or phone so that someone can follow up with you.</font></p>
<hr width="100%">
<p>Name:&nbsp&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="name"></p>
<p>E-mail:&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="email"></p>
<p>Phone:&nbsp&nbsp&nbsp&nbsp<INPUT TYPE="text" SIZE="35" name="phone"></p>
<p>Address:   <INPUT TYPE="text" SIZE="35" name="address"></p><br>
I would like more information on the following (check all that apply):<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Adult Sunday School">Adult Sunday School<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Bible Studies"">Bible Studies<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Children's Programs">Children's programs<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Missions">Missions<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Music">Music/Choir<br>
<INPUT TYPE="checkbox" NAME="Programs[]" VALUE="Youth">Youth group<br><br>
Please add any additional comments or questions in the box below:<br>
<TEXTAREA NAME="comments" ROWS=10 COLS=60>
</TEXTAREA>
<br><br>
<p><img src="Cap_Img.php"><br><br>
<input type="button" value="Refresh Image" onClick="window.location.href=window.location.href"></p>
<p>Before submitting your request, please enter the string shown in the image into the box below.</p>
<p><input name="number" type="text"></p>
<input type="submit" name="submit" value="Submit"><br><br>
<hr width="100%">

</div>
</body>

</html>


 

 

feedback.php code:

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<body>
<?php
$checkbox0 = $_POST['Programs'][0];
$checkbox1 = $_POST['Programs'][1];
$checkbox2 = $_POST['Programs'][2];
$checkbox3 = $_POST['Programs'][3];
$checkbox4 = $_POST['Programs'][4];
$checkbox5 = $_POST['Programs'][5];
?>
<?php
$formBody="Name:$name\nEmail:$email\nPhone:$phone\nAddress:$address\nI'd like more information on the following programs: $checkbox0, $checkbox1, $checkbox2, $checkbox3, $checkbox4, $checkbox5 \nComments:$comments";
$headers = "From:$email";

if ($submit) {
mail("[email protected]", "Church Information Request",$formBody, $headers);
}
if ($submit) {
print "Thank you. Your request has been submitted <br /> <br />";
print "Current date and time :";
print date("F j, Y  g:i A T");
}


?>

</body>
</html>


 

Captcha code:

 



<?php
    session_start();    	
    $md5_hash = md5(rand(0,9999)); 
    $security_code = substr($md5_hash, 25, 5); 
    $enc=md5($security_code);
    $_SESSION['count'] = $enc;
    $secure = $_SESSION['count'];
    //     echo "--------------------------$secure<br>";

    $width = 100;
    $height = 40; 
    
    $image = ImageCreate($width, $height);  
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 100, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);
     
    ImageFill($image, 0, 0, $grey); 
    //Add randomly generated string in white to the image
    ImageString($image, 10, 30, 10, $security_code, $black); 
    ImageRectangle($image,0,16,$width-1,$height-1,$grey); 
    imageline($image, 0, $height/2, $width, $height/2, $grey); 
    imageline($image, $width/2, 0, $width/2, $height, $grey); 

    header("Content-Type: image/jpeg"); 
    ImageJpeg($image);
    ImageDestroy($image);
    ImageDestroy($image);
    ?>




The captcha doesn't appear to actually do anything, but first things first. Change your feedback11.php to the following, and see what happens.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]">
<html>
<body>
<?php
$checkbox0 = $_POST['Programs'][0];
$checkbox1 = $_POST['Programs'][1];
$checkbox2 = $_POST['Programs'][2];
$checkbox3 = $_POST['Programs'][3];
$checkbox4 = $_POST['Programs'][4];
$checkbox5 = $_POST['Programs'][5];
$formBody="Name:$name\nEmail:$email\nPhone:$phone\nAddress:$address\nI'd like more information on the following programs: $checkbox0, $checkbox1, $checkbox2, $checkbox3, $checkbox4, $checkbox5 \nComments:$comments";
$headers = "From:$email";

if ($submit) {
   mail("[email][email protected][/email]", "Church Information Request",$formBody, $headers);
   print "Thank you. Your request has been submitted <br /> <br />";
   print "Current date and time :";
   print date("F j, Y  g:i A T");
} else {
   echo "Submit is NOT set.";
}
?>

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.