Jump to content

Captcha verification image, help?


svenny1

Recommended Posts

Basically i have followed a tutorial for my form, but now i wanted to incorporate the capture image, so bots dont use my form, but the code doesn't seem to function atall, it appears and acts like it is their, but nothing happens if the code is wrong, the form is sent anyway. i have tried loads of different things.. but am unable to find the problem. I used the tuorial for capture from - http://www.phpjabbers.com/captcha-image-verification-php19.html .

 

My html Form - Joinus.html

<table width="234" border="0" cellspacing="0" cellpadding="0" align="center">
<form method="post" action="contact.php">
  <tr>
    <td width="88">PSN:<br></td>
    <td width="146"><input name="psn" type="text" size="12" ><br></td>
  </tr>
  <tr>
    <td>E-Mail: </td>
    <td><input name="email" type="text" size="12" /></td>
  </tr>
  <tr>
    <td>Rank: </td>
    <td><select name="rank" size="1">
<?php
for ($x = 1; $x < 56; $x++) {
?>
<option value="<?php echo $x; ?>"><?php echo $x; ?></option>
<?php
}
?>
</select></td>
  </tr>
  <tr>
    <td>Prestige: </td>
    <td><select name="prestige" size="1">
<?php
for ($x = 1; $x < 11; $x++) {
?>
<option value="<?php echo $x; ?>"><?php echo $x; ?></option>
<?php
}
?>
</select></td>
  </tr>
  <tr>
    <td>K/D Ratio:</td>
    <td><input name="kdratio" type="text" size="12" /></td>
  </tr>
    <tr>
    <td><img src="captcha.php"></td>
    <td><input name="vercode" type="text" size="12" /></td>
  </tr>
  <tr>
    <td colspan="2">
    
      <div align="center"><input type="submit" value="Send Application" />   
      </div>
  </form></td>
  </tr>
</table>

 

My forms contact.php

<?php
$to = "[email protected]";
$subject = "$psn wants to Join";
$psn = $_REQUEST['psn'] ;
$rank = $_REQUEST['rank'] ;
$prestige = $_REQUEST['prestige'] ;
$kdratio = $_REQUEST['kdratio'] ;
$email = $_REQUEST['email'] ;
$headers = "From: $email";

$message = "
$subject
--------------------------------------
Psn :  $psn
Rank :  $rank
Prestige :  $prestige
K/D Ratio :  $kdratio
E-mail Address :  $email
--------------------------------------
";

$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Thank you $psn, your application was sent successfully"; }
else
{print "Sorry $psn we encountered an error sending your mail"; }
?>

 

Now these are the 2 files capture told me to create.

 

Capture.php

<?
session_start();
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;

$height = 25;
$width = 65;

$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14; 
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
?>

 

Submit.php

<?
session_start();
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  {
     echo  '<strong>Incorrect verification code.</strong><br>';
} else {
     // add form data processing code here
 <input type="submit" value="Send Application" />
     echo  '<strong>Verification successful.</strong><br>';
};
?>

 

From where i'm looking at it, the submit.php doesn't seem to get involved in the code atall.

 

Can anybody understand why this is not working :S?

Link to comment
https://forums.phpfreaks.com/topic/112622-captcha-verification-image-help/
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.