Visit the Official PHP Website |
PHP ProgrammingBy James N HitzThe CodeOur code that actually tests the form input to validate and process is as follows: <html><head><title>Your Suggestions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body bgcolor="black" text="white"> <center> <?php if(trim($fName) ==""){ $missing = "<p>The <b>First Name</b> has not been provided."; }elseif(!preg_match("/^\w+$/", $fName)){ $missing .= "<p><b>First Name</b> contains invalid character(s)"; } if(!preg_match("/^\w+$/",$lName)){ $missing .= "<p>The <b>Last Name</b> contains invalid character(s)"; } if(!preg_match("/^(\w+)\@(\w+)\.(\w){2,3}$/",$eAddress)){ $missing .= "<p>Invalid <b>Email Address</b> Provided."; } if(trim($suggestion) ==""){ $missing .= "<p><b>Suggestion</b> is blank."; } if(trim($missing) != ""){ print "<p>There are a few problems with your data entry:</p>". $missing; } else { print "<h2>Thank You</h2>". "<p>Hello <b>". $fName . " " . $lName . "</b><p>Your suggesstions state that". "<br><b>$suggestion</b>\. Your email address <b>". $eAddress . "</b> is valid"; } } ?> <center> </body></html> |
The author has tried his level best to keep the contents in this web site as accurate as possible. This does not however mean that you CANNOT find an error or an in-accuracy. He is only human for heaven's sake. Please let him know by emailing him at james@ncts.zzn.com
JamHitz Productions