Captcha Script

Language
Hi guys, I have here a captcha source code that enables you to generate a random code and protect your page for spammers. You can insert this code to your project as a type of test that the response is generated by a human being. For more question about this code email me at [email protected]. Thank you.
  1. <?php
  2. include('header.php');
  3. ?>
  4. <html>
  5. <body>
  6. <br>
  7. <br>
  8. <form class="form-horizontal" method="POST">
  9.         <div class="control-group">
  10.                 <label class="control-label" for="inputEmail"></label>
  11.                 <div class="controls"> <img  src="generatecaptcha.php?rand=<?php echo rand(); ?>" id='captchaimg' > <a href='javascript: refreshCaptcha();'><i class="icon-refresh icon-large"></i></a>
  12.                         <script language='JavaScript' type='text/javascript'>
  13.                                 function refreshCaptcha()
  14.                                 {
  15.                                         var img = document.images['captchaimg'];
  16.                                         img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
  17.                                 }
  18.                         </script>
  19.                 </div>
  20.         </div>
  21.         <div class="control-group">
  22.                 <label class="control-label" for="inputPassword">Enter the Code Above</label>
  23.                 <div class="controls">
  24.                         <input id="code" name="code" type="text" placeholder="Enter the Code Above" required>
  25.                         </td>
  26.                 </div>
  27.         </div>
  28.         <div class="control-group">
  29.                 <div class="controls">
  30.                         <button type="submit" name="submit" class="btn btn-info">Submit</button>
  31.                 </div>
  32.         </div>
  33. </form>
  34. <?php
  35.  
  36. if(isset($_POST['submit']))
  37. {
  38.         if(strcmp($_SESSION['code'], $_POST['code']) != 0)
  39.         {
  40.         ?>
  41. <div class="span4">
  42.         <div class="alert alert-danger">The captcha code does not match!</div>
  43. </div>
  44. <?php
  45. }else{ ?>
  46. <div class="span4">
  47.         <div class="alert alert-success">Code Match</div>
  48. </div>
  49. <?php
  50. }}
  51. ?>
  52. </body>
  53. </html>

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment