activatiecode

Gesponsorde koppelingen

PHP script bestanden

  1. activatiecode

« Lees de omschrijving en reacties

//////////////// CODE.PHP ////////////////

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
session_start();

$tekens = 'AbCDeFgHiJklmNoPQrStUvWXyZ1234567890';
$code = '';

for ($i=0; $i<3; $i++)
{

    $code .= $tekens {rand (0, strlen ($tekens) - 1)};
}


$_SESSION["auth_code"] = $code;

header("Content-type: image/png");

$image = imagecreatetruecolor(90, 50);
$back = imagecolorallocate($image, 212, 238, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$red = imagecolorallocate($image, 255, 0, 0);

imagefill($image, 0, 0, $back);
imagerectangle($image, 0, 0, 89, 49, $black);

for ($i = 0; $i <= 50; $i+=5)
    imageline($image, mt_rand($i,$i+40), 0, mt_rand($i,$i+40), 50, $black);

for ($i = 0; $i <= 90; $i+=5)
    imageline($image, 0, mt_rand($i,$i+30), 90, mt_rand($i,$i+30), $black);

imagettftext($image, 20, rand(-20, 20), 15, 30, $red, "codefont.ttf", $code);
imagepng($image);
imagedestroy($image);
?>


//////////////// TESTFORM.PHP ////////////////
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    session_start();
    if($_SESSION["auth_code"] == $_POST["code"])
        echo "Code goed!";
    else
        echo "Code fout!";
}

?>

<form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<img src="code.php"><br>
Code: <input type="text" name="code" size=5><input type="submit" value="Zend!">
</form>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.