Page 1 of 1

email pattern help HELP! HELP! HELP!

Posted: Fri Apr 07, 2006 2:01 pm
by turgs
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


the username and password works just fine

but the email doesn;t...and i can't figure out what's wrong...I NEED HELP

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Patterns</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
// if the 'submit' variable does not exist
// from has not been submitted
// display initial page

if (!$_POST['submit'])
 {
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
Username: <input name="username" type="text"><br>
Password: <input name="password" type="password"><br>
Email Address: <input name="email" type="text"><br>
<input name="submit" type="submit" value="Sign Up">
</form>
<?php
}
else
{
	//form submitted
	// validat usernam password and email fields
	// using regular expressions
	$username = (!isset($_POST['username']) ||
	!ereg('^([a-zA-Z]){3,8}$', $_POST['username'])) ?
	die ('ERROR: Enter valid username') :
	mysql_escape_string(trim($_POST['username']));
	
	$password = (!isset($_POST['password']) ||
	!ereg('^([a-z0-9]){5,8}$', $_POST['password'])) ?
	die ('ERROR: Enter valid password') :
	mysql_escape_string(trim($_POST['password']));

	$email = (!isset($_POST['email']) ||
	!ereg('^([a-zA-Z0-9_-]+)([\.a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)
	(\.[a-zA-Z0-9_-]+)+$', $_POST['email'])) ?
	die ('ERROR: Enter valid email') :
	mysql_escape_string(trim($_POST['email']));

	// connect to database
	// save record
}
?>
</body>
</html>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Apr 07, 2006 2:28 pm
by feyd
remove the carriage return in your email regex.

And just so you know, the massive majority of people creating threads here would like help. Proclaiming it in your subject, by shouting no less, and thread don't really mean anything.