<?php$regex = '/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i';if($_POST){ if(!empty($_POST['name'])) { //codes $name = $_POST['name']; } else { $error[]="You must enter your name."; } if(preg_match($regex,$_POST['email'])) { // codes $email = $_POST['email']; } else { $error[]="You did not supply a valid email address."; } $error_msg = empty($error) ? "" : implode(',',$error); header("location:y.php?name=$name&email=$email&error=$error_msg"); }?>
<?phpif(!empty($_GET["error"])){ $errors = explode(",",$_GET["error"]); for($i=0;$i<count($errors);$i++) { echo $errors[$i]."<br />"; } }$name = empty($_GET["name"])?" ":$_GET["name"];$email = empty($_GET["email"])?" ":$_GET["email"];echo "<table border='1'> <tr><th>Name</th><th>Email</th></tr> <tr><td align='center'>$name</td><td align='center'>$email</td></tr><tr> </table> ";?>