View Single Post
  #3 (permalink)  
Old 07-12-09, 01:27 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 2,659
Thanks: 0
Thanked 22 Times in 22 Posts
PHP Code:
<?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");
 }
?>
y.php
PHP Code:
<?php
if(!empty($_GET["error"]))
{
 
$errors explode(",",$_GET["error"]);
 for(
$i=0;$i<count($errors);$i++)
 {
  echo 
$errors[$i]."<br />";
  }
 }
$name = empty($_GET["name"])?"&nbsp;":$_GET["name"];
$email = empty($_GET["email"])?"&nbsp;":$_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> "
;
?>
__________________
Jerry Broughton
Reply With Quote