Nieuw lid |
|
Hallo,
Ik heb via php een script gemaakt dat een afbeelding maakt met een random nummer in, deze number moeten de gebruikers dan overtypen voordat ze hun registratie kunnen voltrekken dit is mijn code:
(image_number.php)
<?php
$chars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n","p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z");
$paswoord="";
for ($i = 0; $i < 6; $i++){
$j = rand("0", "58");
$paswoord .= $chars[$j];
}
//random_number.php
$img_number = imagecreate(100,50);
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$grey_shade = imagecolorallocate($img_number,204,204,204);
imagefill($img_number,0,0,$white);
$number = $paswoord;
Imagestring($img_number,11,32,17,$number,$grey_shade);
Imagestring($img_number,9,30,15,$number,$black);
header("Content-type: image/jpeg");
imagejpeg($img_number);
?>
<?php $chars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n","p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"); $paswoord=""; for ($i = 0; $i < 6; $i++){ $paswoord .= $chars[$j]; } //random_number.php $img_number = imagecreate(100,50); $white = imagecolorallocate($img_number,255,255,255); $black = imagecolorallocate($img_number,0,0,0); $grey_shade = imagecolorallocate($img_number,204,204,204); imagefill($img_number,0,0,$white); $number = $paswoord; Imagestring($img_number,11,32,17,$number,$grey_shade); Imagestring($img_number,9,30,15,$number,$black); header("Content-type: image/jpeg"); imagejpeg($img_number); ?>
Nu roep ik in mijn script (register.php) zelf die afbeelding op met <img src="image_number.php">, alles werkt de afbeelding wordt getoond. Maar nu zou ik op een of andere manier het random nummer dat in de afbeelding staat willen opslaan in een sessie,variabele.
Ik heb geprobeerd in image_number een sessie aan te maken, maar dat lukt langs geen kanten.
Hoe kan ik alsnog te weten komen welke waarde er op de afbeelding staat?
alvast bedankt,
Steve
|