Registratie Formulier Hulp

Gestart doorSkytop2 reacties11 weergaven

3 berichten · pagina 1 van 1

Skytop

Lid · Topicstarter

Berichten
1.101
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik heb vanmorgen een klein registratie formuliertje gemaakt,
Alleen ik krijg al direct de error "Gebruikersnaam is te lang",
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
connect[COLOR= #007700]();[/COLOR]

[COLOR= #FF8000]// Registratie $_POST variables.[/COLOR]
[COLOR= #0000BB]$name[/COLOR] [COLOR= #007700]=[/COLOR] anti[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] anti[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] anti[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strtoupper"]strtoupper[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]:[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/strtoupper"]strtoupper[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]));[/COLOR]

[COLOR= #FF8000]// We willen controleren of de lengte toegestaan is.[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]12[/COLOR] [COLOR= #007700]) {[/COLOR]
    [COLOR= #FF8000]// We willen controleren op verboden karakters.[/COLOR]
    [COLOR= #0000BB]$chars[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"!"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"@"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"#"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"%"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"^"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"&"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"*"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"("[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]")"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"{"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"}"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"\"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"/"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]":"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"<"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]">"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]","[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"."[/COLOR][COLOR= #007700]);[/COLOR]

    [COLOR= #0000BB]$new[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$chars[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700]);[/COLOR]

    [COLOR= #FF8000]// We willen controleren of de gebruiker bestaat.[/COLOR]
    [COLOR= #0000BB]$checkuser[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT username FROM users WHERE username=$username"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$username_exist[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$checkuser[/COLOR][COLOR= #007700]);[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username_exist[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Sorry, Deze gebruikersnaam is al bezet."[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=register.php>Terug</a>"[/COLOR][COLOR= #007700];
    }[/COLOR]

    [COLOR= #FF8000]// Alle controles waren prima, dus gaan we de gebruiker registreren.[/COLOR]
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO users (name, email, username, password)
    VALUE($name,$email,$username,$password)"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
    [URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]();[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Registratie succesvol voltooid!"[/COLOR][COLOR= #007700];[/COLOR]

    [COLOR= #FF8000]// Nu mailen we de informatie naar zijn email adres.[/COLOR]

     [COLOR= #0000BB]$yoursite[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]www.whiterock-gaming.net[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$webmaster[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Skytop[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$youremail[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]registratie@whiterock-gaming.net[/COLOR][COLOR= #007700];[/COLOR]

    [COLOR= #0000BB]$onderwerp[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je bent geregistreerd bij $yoursite."[/COLOR][COLOR= #007700];[/COLOR]
      [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Hallo $name, 
      
                  Je bent succesvol geregistreerd,
                  Om in te loggen ga je naar onze site daar vind,
                  Je het login formulier.
                  
                  Veel Succes!
                  $webmaster"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/mail"]mail[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$email[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$subject[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$message[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"From: $yoursite <$youremail>
X-Mailer:PHP/"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/phpversion"]phpversion[/URL][COLOR= #007700]());    
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/Echo"]Echo[/URL] [COLOR= #DD0000]"Je gebruikersnaam is te lang!"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
Hoe los ik dit op?
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if($username_exist > 0){
        echo "Sorry, Deze gebruikersnaam is al bezet.";
        echo "<a href=register.php>Terug</a>";
    } <je sluit hem af geen else if iets

    // Alle controles waren prima, dus gaan we de gebruiker registreren.
    $query = "INSERT INTO users (name, email, username, password)
    VALUE($name,$email,$username,$password)";
    mysql_query($query) or die(mysql_error());
    mysql_close();

    echo "Registratie succesvol voltooid!";

    // Nu mailen we de informatie naar zijn email adres.

     $yoursite = www.whiterock-gaming.net;
    $webmaster = Skytop;
    $youremail = registratie@whiterock-gaming.net;

    $onderwerp = "Je bent geregistreerd bij $yoursite.";
      $bericht = "Hallo $name, 
      
                  Je bent succesvol geregistreerd,
                  Om in te loggen ga je naar onze site daar vind,
                  Je het login formulier.
                  
                  Veel Succes!
                  $webmaster";
    mail($email, $subject, $message, "From: $yoursite <$youremail>nX-Mailer:PHP/".phpversion());    
} else {
hier begin je weer
0
Skytop

Lid · Topicstarter

Berichten
1.101
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Smiegles schreef:
if($username_exist > 0){
        echo "Sorry, Deze gebruikersnaam is al bezet.";
        echo "<a href=register.php>Terug</a>";
    } <je sluit hem af geen else if iets

    // Alle controles waren prima, dus gaan we de gebruiker registreren.
    $query = "INSERT INTO users (name, email, username, password)
    VALUE($name,$email,$username,$password)";
    mysql_query($query) or die(mysql_error());
    mysql_close();

    echo "Registratie succesvol voltooid!";

    // Nu mailen we de informatie naar zijn email adres.

     $yoursite = www.whiterock-gaming.net;
    $webmaster = Skytop;
    $youremail = registratie@whiterock-gaming.net;

    $onderwerp = "Je bent geregistreerd bij $yoursite.";
      $bericht = "Hallo $name, 
      
                  Je bent succesvol geregistreerd,
                  Om in te loggen ga je naar onze site daar vind,
                  Je het login formulier.
                  
                  Veel Succes!
                  $webmaster";
    mail($email, $subject, $message, "From: $yoursite <$youremail>nX-Mailer:PHP/".phpversion());    
} else {
hier begin je weer
Sorry ik ben beginner in PHP,

EDIT: Kreeg het voor elkaar hier mag slotje op biggrin
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren