cyrixware Posted March 3, 2008 Share Posted March 3, 2008 Hi i just want to know how to create or generate codes in php. ex. ||textbox|| 'Enter the codes shown below' Any idea is highly appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 3, 2008 Share Posted March 3, 2008 you mean something like captcha codes.. an image generated to minimize spam? Quote Link to comment Share on other sites More sharing options...
unsider Posted March 3, 2008 Share Posted March 3, 2008 Similar to the images on registration forms? Quote Link to comment Share on other sites More sharing options...
cyrixware Posted March 3, 2008 Author Share Posted March 3, 2008 yep something like that.... before you can finish the regstration you must enter first the codes shown on the screen. (note: codes not in image form, something generated in database) Quote Link to comment Share on other sites More sharing options...
unsider Posted March 3, 2008 Share Posted March 3, 2008 You write a script that jus generates random string of #/letters, and then outputs that wherever you want? Then have a script check that generated code matches what the user has input. Google a tutorial if thats all you want.. Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 3, 2008 Share Posted March 3, 2008 oh men... from DB? weird maybe try this first <?php // create a 100*30 image $im = imagecreate(100, 30); // white background and blue text $bg = imagecolorallocate($im, 200, 200, 200); $textcolor = imagecolorallocate($im, 0, 0, 255); // write the string at the top left $array = range('A','Z'); $array2 = range(0,9); $newarray = array_merge($array2,$array); shuffle($newarray); foreach($newarray as $val){ ++$x; $value .=$val ; if($x == 7){ break; } } imagestring($im, 5, 20, 5,$value, $textcolor); // output the image header("Content-type: image/png"); imagepng($im); ?> simple but that should work Quote Link to comment Share on other sites More sharing options...
cyrixware Posted March 3, 2008 Author Share Posted March 3, 2008 oh men... from DB? weird maybe try this first <?php // create a 100*30 image $im = imagecreate(100, 30); // white background and blue text $bg = imagecolorallocate($im, 200, 200, 200); $textcolor = imagecolorallocate($im, 0, 0, 255); // write the string at the top left $array = range('A','Z'); $array2 = range(0,9); $newarray = array_merge($array2,$array); shuffle($newarray); foreach($newarray as $val){ ++$x; $value .=$val ; if($x == 7){ break; } } imagestring($im, 5, 20, 5,$value, $textcolor); // output the image header("Content-type: image/png"); imagepng($im); ?> simple but that should work Thanks Bro. Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 3, 2008 Share Posted March 3, 2008 yan ba yun? ungas namn tanong mo pre... your question is very unclear but nice to know that helps.. Quote Link to comment Share on other sites More sharing options...
cyrixware Posted March 3, 2008 Author Share Posted March 3, 2008 yan ba yun? ungas namn tanong mo pre... your question is very unclear but nice to know that helps.. What i mean is the codes shown is from database stored as what unsider says.... hehehe Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 3, 2008 Share Posted March 3, 2008 then just replace the randomized letters and num there with your DB info Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.