Hallo,
ich habe ein Problem: Ich möchte einen Bestätigungscode-Generator bauen und dieses Code auf mehreren Seiten anzeigen lasse. Den Bestätigungscode erstelle ich durch Zufallszahlen von 1-35, die dann in Buchstaben und Zahlen umgewandelt werden. Leider sind die Zufallszahlen aber immer unterschiedlich, wenn ich diese auf 2 Seiten ausgeben möchte. Aber nun genug geredet, jetzt kommt mein Ansatz: ^^
bestaetigungscode.php:
best_code.php
Danach würde ich gerne den Code ausgeben, aber leider wird beispielsweise $code1 immer unterschiedlich ist. Wie kann ich das gestalten, dass der Code auf beiden Seiten gleich ist?
Vielen Dank!
Grüße
ich habe ein Problem: Ich möchte einen Bestätigungscode-Generator bauen und dieses Code auf mehreren Seiten anzeigen lasse. Den Bestätigungscode erstelle ich durch Zufallszahlen von 1-35, die dann in Buchstaben und Zahlen umgewandelt werden. Leider sind die Zufallszahlen aber immer unterschiedlich, wenn ich diese auf 2 Seiten ausgeben möchte. Aber nun genug geredet, jetzt kommt mein Ansatz: ^^
bestaetigungscode.php:
PHP-Code:
<?php
header ("Content-type: image/png");
include ('.../best_code.php');
$x1 = rand(30, 40);
$y1 = rand(50, 100);
$d1 = rand(-45,45);
$x2 = rand(100, 110);
$y2 = rand(50, 100);
$d2 = rand(-45,45);
$x3 = rand(170, 180);
$y3 = rand(50, 100);
$d3 = rand(-45,45);
$x4 = rand(240, 250);
$y4 = rand(50, 100);
$d4 = rand(-45,45);
$x5 = rand(310, 320);
$y5 = rand(50, 100);
$d5 = rand(-45,45);
$x6 = rand(380, 390);
$y6 = rand(50, 100);
$d6 = rand(-45,45);
$im = @ImageCreate (425, 125)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 150, 150, 150);
$text_color = ImageColorAllocate ($im, 0, 0, 0);
ImageTTFText ($im, 30, $d1, $x1, $y1, $text_color, "fonts/VERA.ttf",
$code1);
ImageTTFText ($im, 30, $d2, $x2, $y2, $text_color, "fonts/VERA.ttf",
$code2);
ImageTTFText ($im, 30, $d3, $x3, $y3, $text_color, "fonts/VERA.ttf",
$code3);
ImageTTFText ($im, 30, $d4, $x4, $y4, $text_color, "fonts/VERA.ttf",
$code4);
ImageTTFText ($im, 30, $d5, $x5, $y5, $text_color, "fonts/VERA.ttf",
$code5);
ImageTTFText ($im, 30, $d6, $x6, $y6, $text_color, "fonts/VERA.ttf",
$code6);
ImagePNG ($im);
?>
PHP-Code:
<?php
/****** Zahlencodes ******/
/********** 1:A **********/
/********** 2:B **********/
/********** 3:C **********/
/********** 4:D **********/
/********** 5:E **********/
/********** 6:F **********/
/********** 7:G **********/
/********** 8:H **********/
/********** 9:I **********/
/********** 10J **********/
/********** 11:K **********/
/********** 12:L **********/
/********** 13:M **********/
/********** 14:N **********/
/********** 15:O **********/
/********** 16:P **********/
/********** 17:Q **********/
/********** 18:R**********/
/********** 19:S **********/
/********** 20:T **********/
/********** 21:U **********/
/********** 22:V **********/
/********** 23:W **********/
/********** 24:X **********/
/********** 25:Z **********/
/********** 26:0 **********/
/********** 27:1 **********/
/********** 28:2 **********/
/********** 29:3 **********/
/********** 30:4 **********/
/********** 31:5 **********/
/********** 32:6 **********/
/********** 33:7 **********/
/********** 34:8 **********/
/********** 35:9 **********/
/**** Zahlencodes Ende ****/
$code[0] = "A";
$code[1] = "B";
$code[2] = "C";
$code[3] = "D";
$code[4] = "E";
$code[5] = "F";
$code[6] = "G";
$code[7] = "H";
$code[8] = "I";
$code[9] = "J";
$code[10] = "K";
$code[11] = "L";
$code[12] = "M";
$code[13] = "N";
$code[14] = "O";
$code[15] = "P";
$code[16] = "Q";
$code[17] = "R";
$code[18] = "S";
$code[19] = "T";
$code[20] = "U";
$code[21] = "V";
$code[22] = "W";
$code[23] = "X";
$code[24] = "Y";
$code[25] = "Z";
$code[26] = "0";
$code[27] = "1";
$code[28] = "2";
$code[29] = "3";
$code[30] = "4";
$code[31] = "5";
$code[32] = "6";
$code[33] = "7";
$code[34] = "8";
$code[35] = "9";
$zahl1 = rand(0, 35);
$zahl2 = rand(0, 35);
$zahl3 = rand(0, 35);
$zahl4 = rand(0, 35);
$zahl5 = rand(0, 35);
$zahl6 = rand(0, 35);
$code1 = $code[$zahl1];
$code2 = $code[$zahl2];
$code3 = $code[$zahl3];
$code4 = $code[$zahl4];
$code5 = $code[$zahl5];
$code6 = $code[$zahl6];
?>
Vielen Dank!
Grüße

Kommentar