HELP what is wrong with my code?
Posted: Tue Sep 07, 2010 10:03 pm
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<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>
<?php
echo phpversion();
$error_text_firstname = "basictext";
$error_text_lastname = "basictext";
$error_text_email = "basictext";
if (isset($_POST['validate_user_data_button'])){
$email_pattern = '/.*@.*\..*/';
$firstname_pattern = '/[^A-Za-z-]/';
$lastname_pattern = '/[^A-Za-z-]/';
$user_firstname = trim($_POST['first_name']);
$user_lastname = trim($_POST['last_name']);
$user_email = trim($_POST['email_address']);
// echo "Variables FIRST NAME___" . "$user_firstname" . "__LAST NAME__" . "$user_lastname" . "__EMAIL__" . "$user_email";
if (preg_match($lastname_pattern, $user_lastname) > 0 )
{
$error_text_lastname = "basictext";
}
else
{
$errot_text_lastname = "errortext";
}
if (preg_match ($email_pattern, $user_email) > 0)
{
$error_text_email = "basictext";
}
else
{
$error_text_email = "errortext";
}
if (preg_match($firstname_pattern, $user_firstname) > 0)
{
$error_text_firstname = "basictext";
}
else
{
$error_text_firstname = "errortext";
}
if ($error_text_firstname == "basictext" && $error_text_lastname == "basictext" && $error_text_email == "basictext")
echo "this is where to store stuff into database";
}
?>
<form action="validate_dbstore_user_data.php" method="post">
<span class="<?php print $error_text_firstname; ?>">Firts name:</span>
<input type="text" name="first_name" class="<?php print $error_text_firstname; ?>">
<br>
<span class="<?php print $error_text_lastname; ?>">Last name:</span>
<input type="text" name="last_name" class="<?php print $error_text_lastname; ?>">
<br>
<span class="<?php print $error_text_email; ?>">E-mail address:</span>
<input type="text" name="email_address" class="<?php print $error_text_email; ?>">
<br>
<input type="submit" name="validate_user_data_button" value="Submit.">
</form>
</body>
</html>