noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
example_form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * Project:     Securimage: A PHP class for creating and managing form CAPTCHA images<br />
00005  * File:        securimage.php<br />
00006  * URL:         www.phpcaptcha.org
00007  */
00008 
00009 
00010 session_start();  // Start the session where the code will be stored.
00011 
00012 ?>
00013 <html>
00014 <head>
00015   <title>Securimage Test Form</title>
00016 </head>
00017 
00018 <body>
00019 
00020 <?php
00021 if (empty($_POST)) { ?>
00022 <form method="POST">
00023 Username:<br />
00024 <input type="text" name="username" /><br />
00025 Password:<br />
00026 <input type="text" name="password" /><br /><br />
00027 
00028 <div style="width: 430px; float: left; height: 90px">
00029       <img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=<?php echo md5(time()) ?>" />
00030 
00031         <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
00032                             <param name="allowScriptAccess" value="sameDomain" />
00033                             <param name="allowFullScreen" value="false" />
00034                             <param name="movie" value="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
00035                             <param name="quality" value="high" />
00036                         
00037                             <param name="bgcolor" value="#ffffff" />
00038                             <embed src="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
00039                           </object>
00040 
00041         <br />
00042         
00043         <!-- pass a session id to the query string of the script to prevent ie caching -->
00044         <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
00045 </div>
00046 <div style="clear: both"></div>
00047 Code:<br />
00048 
00049 <!-- NOTE: the "name" attribute is "code" so that $img->check($_POST['code']) will check the submitted form field -->
00050 <input type="text" name="code" size="12" /><br /><br />
00051 
00052 <input type="submit" value="Submit Form" />
00053 </form>
00054 
00055 <?php
00056 } else { //form is posted
00057   include("securimage.php");
00058   $img = new Securimage();
00059   $valid = $img->check($_POST['code']);
00060 
00061   if($valid == true) {
00062     echo "<center>Thanks, you entered the correct code.<br />Click <a href=\"{$_SERVER['PHP_SELF']}\">here</a> to go back.</center>";
00063   } else {
00064     echo "<center>Sorry, the code you entered was invalid.  <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
00065   }
00066 }
00067 
00068 ?>
00069 
00070 </body>
00071 </html>
 All Data Structures Namespaces Files Functions Variables Enumerations