I am new in php
i want to fill a data base but i want to use regular expressions
i want the code to stop filling the database when the input is not correct so that the user can correct his input
i dont know how to do that
at this moment the script tell the input is not correct and fills the rest of the database
when the user corrects his input the database fills the same input again
<?php
Function vuldatabase($afdeling , $voornaam , $achternaam , $email , $telefoonnummer , $locatie)
{
$db = mysql_connect("localhost", "httpmain", "bigmac");
mysql_select_db("learndb", $db);
$sql = "insert into personell (afdeling, voornaam, achternaam, email, telefoonnummer, locatie) values ('$afdeling','$voornaam','$achternaam','$email','$telefoonnummer','$locatie')";
$result = mysql_query($sql);
print ("de database is gevuld<br>\n");
}
Function formcheck($afdeling , $voornaam , $achternaam , $email , $telefoonnummer , $locatie)
{
$patroonafdeling = "[a-z][A-Z]";
$patroonvoornaam = "[a-z][A-Z]";
$patroonachternaam = "[a-z][A-Z]";
$patroonemail = ".+@hr.nl";
$patroontelefoonnummer = "[0-9]";
$patroonlocatie = "[a-z][A-Z]";
if (eregi($patroonafdeling, $afdeling))
{
print ("uw afdelingsnaam is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldige afdelingsnaam op !<br>\n");
};
if (eregi($patroonvoornaam, $voornaam))
{
print ("uw voornaam is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldige voornaam op !<br>\n");
};
if (eregi($patroonachternaam, $achternaam))
{
print ("uw achternaam is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldige achternaam op !<br>\n");
};
if (eregi($patroonemail, $email))
{
print ("uw email is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldig email adres op !<br>\n");
};
if (eregi($patroontelefoonnummer, $telefoonnummer))
{
print ("uw telefoonnummer is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldig telefonnummer op !<br>\n");
};
if (eregi($patroonlocatie, $locatie))
{
print ("uw locatie is goed ontvangen<br>\n");
}
else
{
print ("geef aub een geldige locatie op !<br>\n");
};
}
?>