FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Register.php rejecting email
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Register.php rejecting email [message #29655 is a reply to message #1395] Sat, 07 January 2006 14:05 Go to previous messageGo to previous message
geekmug is currently offline  geekmug   United States
Messages: 5
Registered: January 2006
Karma:
Junior Member
I'm gonna drudge this back up rather than start a new topic. The current validate_email function is still incomplete. In particular, I noticed that it does not support a '+' in the local-part. I did a brief amount of research into finding a fully RFC compliant function and ran across http://www.ilovejackdaniels.com/php/email-address-validation/.

function validate_email($email)
{
	// Orignally by Dave Child, 2004 (http://www.ilovejackdaniels.com/php/email-address-validation/)

	// First, we check that there's one @ symbol, and that the lengths are right
	if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
		// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
		return true;
	}
	// Split it into sections to make life easier
	$email_array = explode("@", $email);
	$local_array = explode(".", $email_array[0]);
	for ($i = 0; $i < sizeof($local_array); $i++) {
		if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
			return true;
		}
	}
	if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
		$domain_array = explode(".", $email_array[1]);
		if (sizeof($domain_array) < 2) {
			return true; // Not enough parts to domain
		}
		for ($i = 0; $i < sizeof($domain_array); $i++) {
			if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
				return true;
			}
		}
	}
	return false;
}


//edited to invert the boolean logic (true = invalid, instead of true = valid).

[Updated on: Sat, 07 January 2006 14:13]

Report message to a moderator

[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Error Log Viewer aborts
Next Topic: Empty Language list on Template Set Selection
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 01 20:37:42 GMT 2024

Total time taken to generate the page: 0.03859 seconds