You’ve already seen the declaration of a variable, manipulations and others, here you will learn how to retrieve and verify data forms.
1- The HTML form:
<form method="post" action="verify.php"> First Name: <input type="text" name="name1"><br /> Last Name: <input type="text" name="name2"><br /> <input type="submit" name="button" value="Send.."> </form>
2- The verify.php file:
<?php
//we verify with the empty() function if the field name1 and name2 are empty
if(empty($_POST['name1']) OR empty($_POST['name2']))
{
//if one of them is empty we print an error message
print 'the field First name and/or Last name is/are empty';
}
//else we print a confirmation message
else{
print 'Thank you '.$_POST['name1'];
}
?>
<?php
//we verify with the regex() function, there are others ways to do this...
//but that will be for the comming lessons.
if(!ereg("\.",$_POST['email']) || !ereg("@",$_POST['email']))
{
//the . or @ or both doesn't exist on the email field
print 'The email address is not valid';
}
else{
print 'email address is ok';
}
?>
thnk u for the good tutorial