note 79560 added to ref.image

From: Date: Mon, 03 Dec 2007 12:35:48 +0000
Subject: note 79560 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-132767@lists.php.net to get a copy of this message
Image Verification using GD for any form. form.php <?php session_start(); //echo $_SESSION['string']; if (isset($_POST['submit'])){ if($_SESSION['string']==md5($_POST['pass'])) { echo "correct code"; } else { echo "incorrect code try again"; } } ?> <html> <body> <form action="form.php" method="post" name="check"> Email : <input type="text" name="email"> <img src="assign.php"><br><br> <input type="text" name="pass"> <input type="submit" name="submit" value="Check"> </form> </body> </html> ===================================== assign.php <?php session_start(); function makerandom($minlength, $maxlength) { $characters = "0123456789"; if ($minlength > $maxlength) { $length = mt_rand ($maxlength, $minlength); } else { $length = mt_rand ($minlength, $maxlength); } $totallen=strlen($characters)-1; for ($i=0; $i<$length; $i++) { $result=$result.$characters[mt_rand(0,$totallen)]; } return $result; } $try=makerandom(4,8); $_SESSION['string']=md5($try); onrefresh($try); function onrefresh($str) { $image=imagecreate(150,70); // something to get a white background with black border $back = imagecolorallocate($image, 0, 0, 0); $border = imagecolorallocate($image, 255, 255, 255); imagefilledrectangle($image, 0, 0, 149,69, $border); imagerectangle($image, 0, 0,149,69, $back); $textcolor=imagecolorallocate($image,255,0,0); //to write string in image imagestring($image, 5, 40, 25, "$str", $textcolor); header('Content-type:image/png'); imagepng($image); } ?> ===================================== ---- Server IP: 203.199.124.111 Probable Submitter: 61.17.14.169 ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- https://master.php.net/note/edit/79560 Del: integrated -- https://master.php.net/note/delete/79560/integrated Del: useless -- https://master.php.net/note/delete/79560/useless Del: bad code -- https://master.php.net/note/delete/79560/bad+code Del: spam -- https://master.php.net/note/delete/79560/spam Del: non-english -- https://master.php.net/note/delete/79560/non-english Del: in docs -- https://master.php.net/note/delete/79560/in+docs Del: other reasons-- https://master.php.net/note/delete/79560 Reject -- https://master.php.net/note/reject/79560 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132767) next »