Wat is er fout?

Gestart doorOne2xs4 reacties32 weergaven

5 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]  
 
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Registreer[/COLOR][COLOR= #007700]])  
{[/COLOR] [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]d/m/Y[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//datum
  //checken of de username al in gebruik is[/COLOR]
  [COLOR= #0000BB]$check_nickname[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT nickname FROM members WHERE nickname=$nickname"[/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]
  [COLOR= #0000BB]$aantal_nickname[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$check_nickname[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal_nickname[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]  
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"De nickname is al in gebruik"[/COLOR][COLOR= #007700];[/COLOR]  
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]nickname[/COLOR][COLOR= #007700]]))[/COLOR]  
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet je nickname invullen"[/COLOR][COLOR= #007700];[/COLOR]  
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]]))[/COLOR]  
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet je voornaam invullen"[/COLOR][COLOR= #007700];[/COLOR]  
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]]))[/COLOR]
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet een achternaam invullen"[/COLOR][COLOR= #007700];[/COLOR]
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]emailadres[/COLOR][COLOR= #007700]]))[/COLOR]
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet je email-adres invullen"[/COLOR][COLOR= #007700];[/COLOR]
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]dag[/COLOR][COLOR= #007700]][/COLOR] or [COLOR= #007700]![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]maand[/COLOR][COLOR= #007700]][/COLOR] or [COLOR= #007700]![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]jaar[/COLOR][COLOR= #007700]])[/COLOR]
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet je geboortedatum volledig invullen"[/COLOR][COLOR= #007700];[/COLOR]
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]))[/COLOR]
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Je moet een password invullen"[/COLOR][COLOR= #007700];[/COLOR]
  [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password2[/COLOR][COLOR= #007700]])[/COLOR]
    [COLOR= #0000BB]$error[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Het eerst password is niet gelijk aan het tweede"[/COLOR][COLOR= #007700];[/COLOR]
 
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700])  
  {[/COLOR] [COLOR= #FF8000]//als er geen error is dan maken we de query[/COLOR]
  [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR][COLOR= #DD0000]"INSERT INTO members (datum, site, nickname, voornaam,
achternaam, emailadres, dag, maand, jaar, password, level)
VALUES ($datum, $site, $nickname, $voornaam, $achternaam,
$emailadres, $dag, $maand, $jaar, $password, 2)"[/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]  
  [COLOR= #FF8000]//query uitoefenen[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"<div align=center>Je bent geregistreerd<br>Je kan nu inloggen</div>"[/COLOR][COLOR= #007700];   
 
  }[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700]) {[/COLOR]  
?>  
<div align="center">
<table width="50%" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td bordercolor="#000000" bgcolor="#CCCCCC" height="36">
    <div align="center">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<font color=black size=-1 face=verdana><b>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</b></font>[/COLOR][COLOR= #007700];[/COLOR] ?></div>
    <form method="post" action="javascript:history.go(-1)">
      <div align=center><input type="submit" name="Terug" value="Terug"></div>
    </form>
   </td>
  </tr>
</table>
</div>
[COLOR= #0000BB]<?php[/COLOR]
  [COLOR= #007700]}   
}[/COLOR]  
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Registreer[/COLOR][COLOR= #007700]])  
{[/COLOR] ?>   
<form method="post" action="">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr><td>Voornaam:</td></tr>
    <tr><td><input type="text" name="voornaam"></td></tr>
    <tr><td>Achternaam:</td></tr>
    <tr><td><input type="text" name="achternaam"></td></tr>
    <tr><td>Nickname:</td></tr>
    <tr><td><input type="text" name="nickname"></td></tr>
    <tr><td>Geboorte datum:</td></tr>
   <tr><td>
      <input type="text" name="dag" size="4" maxlength="2">
      <input type="text" name="maand" size="4" maxlength="2">
      <input type="text" name="jaar" size="8" maxlength="4">
    </td></tr>
    <tr><td>E-mailadres:</td></tr>
    <tr><td><input type="text" name="emailadres"></td></tr>
    <tr><td>Website:</td></tr>
    <tr><td>
    <input type="text" name="site"><br>
    <font size="-2" color="#FF0000">Met http:// ervoor ! Als je geen site hebt veld leeglaten a.u.b</font>
    </td></tr>
    <tr><td>Password:</td></tr>
    <tr><td><input type="password" name="password"></td></tr>
    <tr><td>Nog eens je password:</td></tr>
    <tr><td><input type="password" name="password2"></td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>
      <input type="Submit" name="Registreer" value="Registreer">
      <input type="Reset" name="Reset" value="Wis velden">
    </td></tr>
  </table>
</form>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR] ?>


Hij slaat hem helemaal leeg op in de database:
Afbeelding
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je zet er variabelen in die niet eens bestaan. emo
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Sebastiaanh schreef:
Je zet er variabelen in die niet eens bestaan. emo
Wil je het script even goed maken?
0
Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee, je kijkt maar eens op php.net. Het is nu best irritant aan het wordne.
Gebruik gewoon $_POST?
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Fanhabbo schreef:
Eerdere citaten tonen
Sebastiaanh schreef:
Je zet er variabelen in die niet eens bestaan. emo
Wil je het script even goed maken?
Het script werkt perfect en doet wat het moet doen. Als jij vind dat dit niet zo is heb je dus zelf een fout gedaan. EN het script errort nu dus omdat je inderdaad variables gebruikt die je niet aanmaakt.

[COLOR= #0000BB]<?php
$check_nickname[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT nickname FROM members WHERE nickname=$nickname"[/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]
?>


Je wilt de username uit de tabel members halen waarvan de username $nickname is. Alleen heb je de variable $nickname niet aangemaakt. Zet dus bovenaan je script ergens dit:

[COLOR= #0000BB]<?php
$nickname[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"gebruikersnaam"[/COLOR][COLOR= #007700];[/COLOR]
?>
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