I want to check if the data entered through a form is valid. If not I\'d like to display the error messages below, and the form again without proceeding the lines below (connecting to the MySQL server and so on). I\'m wondering if there is a CASE (or similar) structure in PHP with which I could display each error message, display a new form with the filled out data? Any idea would be of great help.
Thanks again,
Akos, Hungary
The code is as follows:
<?
if ($azonosito == \"\")
{
print(\"<h3>Ervenytelen azonosito!</h3>\") ;
exit ;
}
if ($nev == \"\")
{
print(\"<h3>Ervenytelen nev!</h3>\") ;
exit ;
}
if (!ereg(\"[a-z0-9-]+(\.[a-z0-9-]+)@([0-9a-z][0-9a-z-][0-9a-z]\.)+[a-z]{2}[mtgvu]?$\",$bejelento_email_cime))
{
print(\"<h3>Ervenytelen e-mail cim!</h3>\") ;
exit ;
}
$dbhost = MYHOST ;
$dbuser = MYUSER ;
$dbpass = MYPASS ;
$db = mysql_connect($dbhost,$dbuser,$dbpass) or die(\"Hiba a kapcsolódáskor!\") ;
$dbname = \"gepek\" ;
mysql_select_db($dbname,$db) ;
$ell_query = \"select * from tanszeki_dolgozok where azonosito=$azonosito\" ;
$ell_result = mysql_query($ell_query,$db) ;
$num = mysql_num_rows($ell_result) ;
if ($num<>0)
{
print(\"<h3>A megadott azonosito mar hasznalatban van!</h3>\") ;
exit ;
}
$felv_query = \"insert into tanszeki_dolgozok(azonosito,nev,email_cim)
values(\'$azonosito\',\'$nev\',\'$email_cim\')\" ;
$felv_result = mysql_query($felv_query,$db) ;
if ($felv_result)
{
print(\"<h3>Sikeres adatfelvitel!</h3>\") ;
}
?>
<body>
<a href=\"admin_menu.html\">Vissza</a>
</body>