[PHP] Probleempje

Gestart doorJosnl31 reacties82 weergaven

32 berichten · pagina 1 van 3

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heey allemaal!

Ik ben bezig met een klein CMS script, alleen snap ik iets niet bij het registratiegedeelte.

Ik wil, als een veld niet is ingevuld, een error weergeven met behulp van de volgende code:

[COLOR= #0000BB]<?php[/COLOR] 

[COLOR= #FF8000]//Configuratiebestand includen[/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][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt geen gebruikersnaam ingevuld![/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]Je hebt geen (geldig) wachtwoord ingevuld[/COLOR][COLOR= #007700];
    
}[/COLOR]


?>


De code is nog niet af!

Ik krijg alleen een error op lijn 13.

Kan iemand mij vertellen wat ik fout doe?

Alvast bedankt!biggrin
EDIT:

Heb het probleempje zelf al gevonden, moest gewoon een if zijn! Ik dacht dat je nooit meerdere ifs achter elkaar kon gebruiken? bloos
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lijn 13: elseif(isset($_POST[wachtwoord])){
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Okee, nu heb ik het volgende probleem:

Ik heb nu alle errors gemaakt zeg maar, alleen worden die al getoond voordat er ook nog maar iets is ge-submit.

Dit is de hele code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registreren</title>
</head>

<body>

<div style="line-height:10px; color: #F30; font-family: Verdana, Geneva, sans-serif; font-size: 13px;">
[COLOR= #0000BB]<?php[/COLOR] 

[COLOR= #FF8000]//Configuratiebestand includen[/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][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen gebruikersnaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen voornaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen telefoonnummer ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]));{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) email-adres ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]


?>
</div>


<!-- Registratieformulier -->
<form action="" method="post">
   <table border="0">
      <tr>
         <td><input type="text" name="gebrnaam" value="Gebruikersnaam" size="25px"></td>
      </tr>
      <tr>
         <td><input type="password" name="wachtwoord" value="Wachtwoord" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="voornaam" value="Voornaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="tussenv" value="Tussenvoegsel" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="achternaam" value="Achternaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="telnr" value="Telefoonnummer" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="email" value="E-mailadres" size="25px"></td>
      </tr>
      <tr>
         <td><input type="submit" name="registreren" value="Registreren"></td>
      </tr>

   </table>
</form>


</body>
</html>


Ik hoop dat iemand mij kan helpen!worshippy
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registreren</title>
</head>

<body>

<div style="line-height:10px; color: #F30; font-family: Verdana, Geneva, sans-serif; font-size: 13px;">
[COLOR= #0000BB]<?php[/COLOR] 

[COLOR= #FF8000]//Configuratiebestand includen[/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]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen gebruikersnaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen voornaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen telefoonnummer ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) email-adres ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}
}[/COLOR]

?>
</div>


<!-- Registratieformulier -->
<form action="" method="post">
   <table border="0">
      <tr>
         <td><input type="text" name="gebrnaam" value="Gebruikersnaam" size="25px"></td>
      </tr>
      <tr>
         <td><input type="password" name="wachtwoord" value="Wachtwoord" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="voornaam" value="Voornaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="tussenv" value="Tussenvoegsel" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="achternaam" value="Achternaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="telnr" value="Telefoonnummer" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="email" value="E-mailadres" size="25px"></td>
      </tr>
      <tr>
         <td><input type="submit" name="registreren" value="Registreren"></td>
      </tr>

   </table>
</form>


</body>
</html>
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dankje Erik, het werkt! biggrin
EDIT:

Kan iemand deze code controleren, weet namelijk niet of ik het zo goed heb gedaan!bloos
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registreren</title>
</head>

<body>

<div style="line-height:10px; color: #F30; font-family: Verdana, Geneva, sans-serif; font-size: 13px;">
[COLOR= #0000BB]<?php[/COLOR] 

[COLOR= #FF8000]//Configuratiebestand includen[/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]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen gebruikersnaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen voornaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen achternaam ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen telefoonnummer ingevuld!</li><br />[/COLOR][COLOR= #007700];
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])){[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) email-adres ingevuld</li><br />[/COLOR][COLOR= #007700];
    
}
}[/COLOR]


[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO `leden` (gebrnaam, 
                                       wachtwoord, 
                                       voornaam,
                                       achternaam,
                                       telnr,
                                       email)
                                       
                                                       VALUES 
                                                                                        (
                                                                                         mysql_real_escape($_POST[gebrnaam]),
                                                                                        mysql_real_escape($_POST[wachtwoord]),
                                                                                        mysql_real_escape($_POST[voornaam]),
                                                                                        mysql_real_escape($_POST[tussenv]),
                                                                                        mysql_real_escape($_POST[achternaam]),
                                                                                        mysql_real_escape($_POST[telnr]),
                                                                                        mysql_real_escape($_POST[email])
                                                                                        )
                                       
                                       "[/COLOR][COLOR= #007700])[/COLOR]


?>
</div>


<!-- Registratieformulier -->
<form action="" method="post">
   <table border="0">
      <tr>
         <td><input type="text" name="gebrnaam" value="Gebruikersnaam" size="25px"></td>
      </tr>
      <tr>
         <td><input type="password" name="wachtwoord" value="Wachtwoord" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="voornaam" value="Voornaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="tussenv" value="Tussenvoegsel" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="achternaam" value="Achternaam" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="telnr" value="Telefoonnummer" size="25px"></td>
      </tr>
            <tr>
         <td><input type="text" name="email" value="E-mailadres" size="25px"></td>
      </tr>
      <tr>
         <td><input type="submit" name="registreren" value="Registreren"></td>
      </tr>

   </table>
</form>


</body>
</html>


Alvast bedankt!shiny
0
Berichten
747
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alleen het klopt niet..

if(isset($_POST[gebrnaam])){

echo
  • Je hebt geen gebruikersnaam ingevuld!
  • ;

    }

    isset betekent: bestaat de variable. Als je nu dus het formulier submit bestaat de variable en krijg je dus de foutmelding.

    De juiste code is:

    if($_POST[gebrnaam] == ){

    echo
  • Je hebt geen gebruikersnaam ingevuld!
  • ;

    }

    en het beste is ook nog om alles door een trim() te halen, dat kan je makkelijk doen met een foreach loop, zo voorkom je dat iemand alleen een spatie invult.

    Edit: en ook je else klopt niet.
    Een else moet je ook weer openen en en sluiten.

    Dus:

    }
    else
    {
    //code
    }

    Edit2:
    En bedenk even dat de else in dit geval alleen toepassing heeft op de laatste if. de rest van de errors zals dus wel zichtbaar worden maar toch wordt de gebruiker geregistreerd, lijkt mij niet de bedoeling.

    Aan dit script moet nog heel wat gebeuren voordat het goed werkt.
    0
    Josnl

    Lid · Topicstarter

    Berichten
    3.461
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Oké, bedankt, maar het ging me eigenlijk meer om de queryyummiebloos
    0
    Berichten
    747
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Nee ook je query klopt niet.
    Je moet de variablen en functies buiten de quotes halen.
    0
    Josnl

    Lid · Topicstarter

    Berichten
    3.461
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Oke, bedankt, ik heb ze buiten de quotes gehaald, maar nu krijg ik 2 errors...

    [COLOR= #0000BB]<?php[/COLOR] 
    
    [COLOR= #FF8000]//Configuratiebestand includen[/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]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen gebruikersnaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen voornaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen achternaam ingevuld</li><br />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen telefoonnummer ingevuld!</li><br />[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])){[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) email-adres ingevuld</li><br />[/COLOR][COLOR= #007700];
        
    }
    }
    
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO `leden` (gebrnaam, 
                                           wachtwoord, 
                                           voornaam,
                                           tussenv,
                                           achternaam,
                                           telnr,
                                           email)
                                           
                                                           VALUES 
                                                                                            (
                                                                                             mysql_real_escape($_POST[gebrnaam]),
                                                                                             mysql_real_escape($_POST[wachtwoord] ),
                                                                                             mysql_real_escape($_POST[voornaam] ),
                                                                                             mysql_real_escape($_POST[tussenv] ),
                                                                                             mysql_real_escape($_POST[achternaam] ),
                                                                                             mysql_real_escape($_POST[telnr] ),
                                                                                             mysql_real_escape($_POST[email] )
                                                                                            )
                                           
                    "[/COLOR][COLOR= #007700])
    
    }[/COLOR]
    ?>


    Errors op r.44 en r.67
    0
    Berichten
    747
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    [COLOR= #0000BB]<?php[/COLOR]
    
    [COLOR= #FF8000]//Configuratiebestand includen[/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]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700])
    {[/COLOR]
    
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen gebruikersnaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        
        [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) wachtwoord ingevuld</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        
        [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen voornaam ingevuld!</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        
        [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen achternaam ingevuld</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        
        [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen telefoonnummer ingevuld!</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        
        [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]<li>Je hebt geen (geldig) email-adres ingevuld</li><br />[/COLOR][COLOR= #007700];
            
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR] 
        
            [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO `leden` (gebrnaam,
                                                   wachtwoord,
                                                   voornaam,
                                                   tussenv,
                                                   achternaam,
                                                   telnr,
                                                   email)
          
                           VALUES
                          (
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebrnaam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]voornaam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tussenv[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]achternaam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]telnr[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                           "[/COLOR][COLOR= #007700].[/COLOR]mysql_real_escape[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"
                          )"[/COLOR][COLOR= #007700]);[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Succesvol geregistreerd[/COLOR][COLOR= #007700];
        
        }
    }[/COLOR]
    ?>


    Nu moet het werken.
    Dit is niet de beste manier aangezien je maar 1 error te zien krijgt op deze manier.
    Beter is om alle errors in en array te plaatsen en vervolgens te kijken of er errors in de array staan, zoja ze allemaal laten zien, zonee registreren.
    0
    Josnl

    Lid · Topicstarter

    Berichten
    3.461
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Ehh... Ik heb hem geupload, maar nu staat er helemaal niks meer?yummie
    0
    Berichten
    747
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Omdat het formulier ontbreekt...
    Kom op zeg dat zijn dingen die je zelf ook wel kan zien als je even goed kijkt.
    0
    Josnl

    Lid · Topicstarter

    Berichten
    3.461
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Oops sorry, helemaal overheen gekeken! bloos
    Edit:
    Werkt niet, want ik krijg een error op r.74:

    Fatal error: Call to undefined function mysql_real_escape() in /home/onehosted/domains/onehosted.nl/public_html/klanten/CMS/registreren.php on line 74
    0
    Berichten
    8.602
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    mysql_real_escape_string()
    0
    Berichten
    6.144
    Reputatie
    0
    Punten
    0,00
    Lid sinds
    Laatst gezien
    Arjan schreef:
    Alleen het klopt niet..

    if(isset($_POST[gebrnaam])){

    echo
  • Je hebt geen gebruikersnaam ingevuld!
  • ;

    }

    isset betekent: bestaat de variable. Als je nu dus het formulier submit bestaat de variable en krijg je dus de foutmelding.

    De juiste code is:

    if($_POST[gebrnaam] == ){

    echo
  • Je hebt geen gebruikersnaam ingevuld!
  • ;

    }

    en het beste is ook nog om alles door een trim() te halen, dat kan je makkelijk doen met een foreach loop, zo voorkom je dat iemand alleen een spatie invult.

    Edit: en ook je else klopt niet.
    Een else moet je ook weer openen en en sluiten.

    Dus:

    }
    else
    {
    //code
    }

    Edit2:
    En bedenk even dat de else in dit geval alleen toepassing heeft op de laatste if. de rest van de errors zals dus wel zichtbaar worden maar toch wordt de gebruiker geregistreerd, lijkt mij niet de bedoeling.

    Aan dit script moet nog heel wat gebeuren voordat het goed werkt.
    Zeg het dan helemaal goed,
    Gebruik daar gewoon de empty() functie voor.
    if(empty($_POST[veldnaam])) {
    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