Jump to content


Photo

email validation


  • Please log in to reply
7 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 September 2006 - 01:45 PM

I need to validate an email to a specific format, but it has to be something that is 100% accurate.  I have to get something that has
something@something.upenn.edu
I have to be able to check for the ".upenn.edu" on the email address
and return an error if it doesn't match, does anyone have any ideas.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 14 September 2006 - 01:49 PM

See this topic and the references in my signature. If you have trouble, show us your code.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 September 2006 - 02:35 PM

if (!eregi(.!upenn.edu($email)) {
$errorhandler .= "The email address is invalid for that school";
}
Is that even close?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 14 September 2006 - 03:09 PM

Please re-read the topic. Use the existing code as-is to match the e-mail, then attempt to customize it.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 September 2006 - 03:44 PM

I did it, I actually came up with something, with regular expressions, from using a book, I thought I would never get the hang of regular expressions, and hte best thing is, it actually worked
<?php
if ($yourschool == "UPenn") {
   if (!ereg('\.upenn\.edu', $email)) {
   $errorhandler .= "The email address is not of the proper school format.<br />";
	}
}
?>

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 14 September 2006 - 03:47 PM

pretty good, but the only problem is that i could enter ".upenn.edu" as my email address, and it will match your check. you need to make it a bit more rigid. try something like this:
<?php
if (!preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.upenn\.edu$|i', $email)) {
  // invalid email address
}
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#7 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 14 September 2006 - 03:48 PM

If you also want to validate it's an email (so strings like "4895.upenn.edu384" will return false), try this:
<?php
if (strtolower($yourschool) == "upenn") {
   if (!eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+\.upenn\.edu$', $email)) {
   $errorhandler .= "The email address is not of the proper school format.<br />";
	}
}
?>

**Note- Haven't tested it.

Orio.

EDIT- obsidian got me :P
Think you're smarty?

(Gone until 20 to November)

#8 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 September 2006 - 04:45 PM

Ah thinks, that will make it alot more secure, thanks for the help, I appreciate it.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users