• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Problem mit rand()

Status
Für weitere Antworten geschlossen.

yoshi95

Neues Mitglied
Code:
[SIZE=2][COLOR=#7f00f0]$code[/COLOR][/SIZE][I][SIZE=2][COLOR=#007ff0]=[/COLOR][/SIZE][/I][SIZE=2][COLOR=#0000f0]rand[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#008000]1[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000],[/COLOR][/SIZE][SIZE=2][COLOR=#008000]99999999999[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]@[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]mysql_connect[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"localhost"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000],[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000],[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000])[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]or[/COLOR][/SIZE][SIZE=2] [B]die[/B][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"Verbindung zu MySQL gescheitert"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]@[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]mysql_select_db[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000])[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]or[/COLOR][/SIZE][SIZE=2] [B]die[/B][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"Datenbankzugriff gescheitert"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#7f00f0]$sql[/COLOR][/SIZE][I][SIZE=2][COLOR=#007ff0]=[/COLOR][/SIZE][/I][SIZE=2][COLOR=#0000f0]"INSERT INTO `member` ( `id` , `name` , `email` , `passwort` , `rasse` , `aktiv` , `test` , `code` ) VALUES ('', '"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"name"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"', '"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"email"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"', '"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"passwort1"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"', '"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"rasse"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"', '0', '0', '"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$code[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000] .[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"');"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0]mysql_query[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$sql[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0]mail[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]([/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"email"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]],[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"Anmeldung bei ???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000],[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0]Hallo, [/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000f0]Du hast dich ??? angemeldet. Bitte klicke auf folgenden Link, um deine Registrierung abzuschließen: [URL]http://???/activate.php?name[/URL]="[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$_POST[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"name"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"&code="[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000].[/COLOR][/SIZE][SIZE=2][COLOR=#7f00f0]$code[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000] .[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0]Mit freundlichen Grüßen,[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000f0]???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000],[/COLOR][/SIZE][SIZE=2][COLOR=#0000f0]"FROM: ???"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]);[/COLOR][/SIZE]

Das ist meine Anmeldebestätigung.
Immer, wenn ich es absende, kommt in der E-Mail eine andere Zahl aus der Variable $code als die, die in der DB gespeichert wird...
 
Ohne mir jetzt den Rest des Codes oder den genauen Zweck angesehen zu haben sage ich einfach mal:
PHP:
$code = md5(time());
Wenn du die gleiche Variable "mailst", wie du speicherst dann sollte es gehen.

BTW: Der Code wäre mit Zeilenumbrüchen und dem foreneigenen Syntax-highlighting besser zu lesen :roll:
 
PHP:
<?php

$link = mysql_connect("...", "...", "...");
mysql_select_db("...", $link);

mt_srand((double)microtime() * 1000000);
$nummer = mt_rand(10000000, 99999999);
$change = true;

if( !empty( $_GET['email'] ) )
{
    $email = mysql_real_escape_string( htmlentities( $_GET['email'], ENT_QUOTES ) );
    $num = @mysql_query("SELECT `nummer` FROM `user` WHERE `userEmail`='" . $email . "'", $link);
    
    if( mysql_num_rows( $num ) != 0 )
    {
        $num = mysql_fetch_assoc( $num );
        $nummer = $num['nummer'];
    }
    else
    {
        $nummer = false;
    }
    
    $change = false;
}

if( $change && !empty( $_POST['email'] ) )
{
    $email = mysql_real_escape_string( htmlentities( $_POST['email'], ENT_QUOTES ) );
    @mysql_query("UPDATE `user` SET `nummer`='" . $nummer . "' WHERE `userEmail`='" . $email . "'", $link);
}

if( $nummer )
{
    // Email neu versenden mit der nummer ( $nummer ) ;) ^^
}
else
{
    echo "Die Angegebene E-Mail existiert nicht!";
}

?>
 
Ohne mir jetzt den Rest des Codes oder den genauen Zweck angesehen zu haben sage ich einfach mal:
PHP:
$code = md5(time());
Wenn du die gleiche Variable "mailst", wie du speicherst dann sollte es gehen.

BTW: Der Code wäre mit Zeilenumbrüchen und dem foreneigenen Syntax-highlighting besser zu lesen :roll:
Sorry, bei mir zeigt er es mit Umbrüchen an.



Ok, jetzt gehts. Danke
 
Zuletzt bearbeitet:
Status
Für weitere Antworten geschlossen.
Zurück
Oben