Jump to content

Generate Codes


cyrixware

Recommended Posts

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..

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.