index.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // Make the page validate
  3. ini_set('session.use_trans_sid', '0');
  4. // Include the random string file
  5. require 'rand.php';
  6. // Begin the session
  7. session_start();
  8. // Set the session contents
  9. $_SESSION['captcha_id'] = $str;
  10. ?>
  11. <!doctype html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="utf-8">
  15. <title>AJAX CAPTCHA</title>
  16. <script src="../../lib/jquery.js"></script>
  17. <script src="../../dist/jquery.validate.js"></script>
  18. <script src="captcha.js"></script>
  19. <link rel="stylesheet" href="style.css">
  20. <style>
  21. img {
  22. border: 1px solid #eee;
  23. }
  24. p#statusgreen {
  25. font-size: 1.2em;
  26. background-color: #fff;
  27. color: #0a0;
  28. }
  29. p#statusred {
  30. font-size: 1.2em;
  31. background-color: #fff;
  32. color: #a00;
  33. }
  34. fieldset label {
  35. display: block;
  36. }
  37. fieldset div#captchaimage {
  38. float: left;
  39. margin-right: 15px;
  40. }
  41. fieldset input#captcha {
  42. width: 25%;
  43. border: 1px solid #ddd;
  44. padding: 2px;
  45. }
  46. fieldset input#submit {
  47. display: block;
  48. margin: 2% 0% 0% 0%;
  49. }
  50. #captcha.success {
  51. border: 1px solid #49c24f;
  52. background: #bcffbf;
  53. }
  54. #captcha.error {
  55. border: 1px solid #c24949;
  56. background: #ffbcbc;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <h1><acronym title="Asynchronous JavaScript And XML">AJAX</acronym> <acronym title="Completely Automated Public Turing test to tell Computers and Humans Apart">CAPTCHA</acronym></h1>
  62. <form id="captchaform" action="">
  63. <fieldset>
  64. <div id="captchaimage"><a href="<?php echo htmlEntities($_SERVER['PHP_SELF'], ENT_QUOTES); ?>" id="refreshimg" title="Click to refresh image"><img src="images/image.php?<?php echo time(); ?>" width="132" height="46" alt="Captcha image"></a></div>
  65. <label for="captcha">Enter the characters as seen on the image above (case insensitive):</label>
  66. <input type="text" maxlength="6" name="captcha" id="captcha">
  67. <input type="submit" name="submit" id="submit" value="Check">
  68. </fieldset>
  69. </form>
  70. <p>If you can&#39;t decipher the text on the image, click it to dynamically generate a new one.</p>
  71. </body>
  72. </html>