<!-- From "User-Friendly Form Validation with PHP and CSS" at http://www.onlamp.com/pub/a/php/2004/04/22/php_css_forms.html --> <? $message = ""; $emailclass = "basictext"; $username = ""; if ($_POST['process'] == 1) { $pattern = '/.*@.*\..*/'; $email = $_POST['email']; $urlname = urlencode($$_POST['username']); if (preg_match($pattern, $_POST['email']) > 0) { // Here's where you would store // the data in a database... header( "location: thankyou.php?&username=$urlname"); } $message = "Please enter a valid email address."; $username = $_POST['name']; $emailclass = "errortext"; } ?> <html> <style> .basictext { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color:#000066; } .errortext { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color:#C00000; font-weight: bold; } </style> <body> <form action="email.php" method="post"> <? if ($message != "") { print '<span class="errortext">'. $message."<span><br>\n"; } ?> <span class="<?print $emailclass; ?>"> Email address:</span> <input name="email" type="text" class="<? print $emailclass; ?>"><br> <span class="basictext">Your name:</span> <input name="name" type="text" class="basictext" value="<?print $username; ?>"><br> <input type="hidden" name="process" value="1"> <input type="submit" name="Button1" value="Sign up!"> </form> </body></html>