I have a script that catches everything wrong what users filled in in a form.
Now, if they fill everything in right, the query should execute.
This is my script:
<?php
if(preg_match("/^.*(?=.{8,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $wachtwoord) === 0)
{
echo '<font>Wachtwoord moet minstens 8 tekens lang zijn, een kleine letter, grote letter én cijfer bevatten.<br><font>';
}
else
{
$wachtwoord = 'goed';
}
if(preg_match("/^[0-9]{10}+$/", $telefoonnummer) === 0)
{
echo '<font>Het telefoonnummer moet 10 cijfers bevatten.<br><font>';
}
else
{
$telefoonnummer = 'goed';
}
if(preg_match("/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/", $gbdatum) === 0)
{
echo '<font>Geboorte datum moet op dit formaat ingevoerd worden: JJJJ-MM-DD<br><font>';
}
else
{
$gbdatum = 'goed';
}
if(preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", $email) === 0)
{
echo '<font>Email moet hier op lijken: email@provider.com<br><font>';
}
else
{
$email = 'goed';
}
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $voornaam) === 0)
{
echo '<font>Voornaam is niet geldig ingevoerd, heeft u een hoofdletter gebruikt?<br><font>';
}
else
{
$voornaam = 'goed';
}
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $achternaam) === 0)
{
echo '<font>Achternaam is niet geldig ingevoerd, heeft u een hoofdletter gebruikt?<br><font>';
}
else
{
$achternaam = 'goed';
}
if ($geslacht == '')
{
echo '<font>U heeft uw geslacht niet aangegeven<br><font>';
}
else
{
$geslacht = 'goed';
}
if(preg_match("/^[a-zA-Z]+\ +[0-9]+$/", $adres) === 0)
{
echo '<font>Adres is verkeerd ingevoerd<br><font>';
}
if(preg_match("/^[a-zA-Z\s]+$/", $woonplaats) === 0)
{
echo '<font>Woonplaats is verkeerd ingevoerd<br><font>';
}
if (ABOVE STATEMENTS DONT APPLY)
{
mysql_query($query);
echo "<font>Uw registratie is succesvol verwerkt <br>Log <a href='login.php' MEDIA=screen>hier</a> in<font>";
}
?>
Now what do I put in in if (ABOVE STATEMENTS DONT APPLY) so it will run the script IF everything is put in the form right.
Thanks in advance!
EDIT:
You can ignore
else
{
$geslacht = 'goed';
}
That was something I tried in the last IF. (like if ($1 && $2 = ‘goed’) but that didn’t work anyway.
Add a simple catch-all boolean.
At the start add in
right after
<?phpThen, in your conditional checks, if any of them fails change the boolean to
falselike this:If you include that
$canContinue=false;in all of the statements, you can have your last if statement like this: