CAPTCHA protection - php Form

Author Topic: CAPTCHA protection  (Read 10278 times)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +11/-0
  • Gender: Male
    • View Profile
CAPTCHA protection
« on: April 15, 2009, 06:39:55 AM »
Download: Members

Demo: http://phpform.net/captcha_v1.php

PHP Form Example:

form.php
Code: [Select]
<?php
session_start
(); 
?>

<script language="JavaScript">
var nReload = 8;
function reloadImg(id) {

if (nReload <= 2)
        if (nReload <= 0)
        {
            alert("Sorry, too many reloads.");
            return;
        }
        else
            alert("Only " + nReload + " more reloads are allowed");
    nReload--;
   var obj = document.getElementById(id);
   var src = obj.src;
   var pos = src.indexOf('?');
   if (pos >= 0) {
      src = src.substr(0, pos);
   }
   var date = new Date();
   obj.src = src + '?v=' + date.getTime();
   return false;
}
</script>
<center>
<div align=center>

<form method="POST" action="members.php">
Username<br>
<input name="username" size="60" maxlength="255"><br>
Password<br>
<input name="password" size="60" maxlength="255"><br>
<img src="captcha.php" id="img" border="1" title="captcha image"><br>
<a href="#" onClick="return reloadImg('img');"><font size=1 face=tahoma  color=black>Reload Image</a><br><br>
<input type="text" style="font-size: 14px; font-family: 'Trebuchet MS';  font-weight: bold;
color: #4D4D4E; BORDER: #000000 2px dotted ;"  size="25" name="check"><br>
<u>Security Text</u>
<br><br>
<input type="submit" name="submit" value="SUBMIT">
<input type="reset" name="reset" value="RESET">
</form>  </font>




</center>
members.php
Code: [Select]
<?php 
session_start
(); 
if((
$_POST['check']) == $_SESSION['check']) { 
echo
"<center><font size=\"1\" face=\"tahoma\" color=\"black\">Thank You";
}else{ 
echo
"<center><font size=\"1\" face=\"tahoma\" color=\"black\">Wrong Security Text <a href=\"javascript:history.go(-1)\">Go Back</a></font></center>";  
die();      
}
?>

code code code
<?php
//session_destroy();
?>

« Last Edit: January 26, 2010, 10:10:44 PM by admin »

Offline KillaKDM

  • Supporter
  • **
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: CAPTCHA protection
« Reply #1 on: June 05, 2010, 06:32:32 PM »
$file = ".tff"

//random font fix
$fonts = array('arial','comic','constani','kristen','tahoma','verdana','vrinda');
$randFont = rand(0,sizeof($fonts)-1);
$Font = $fonts[$randFont];
$font = 'fontf/'.$Font.$file;

hope thats helpful to someone ;D