Jump to content

email validation


Ninjakreborn

Recommended Posts

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
[code]<?php
if ($yourschool == "UPenn") {
  if (!ereg('\.upenn\.edu', $email)) {
  $errorhandler .= "The email address is not of the proper school format.<br />";
}
}
?>[/code]
Link to comment
Share on other sites

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:
[code]
<?php
if (!preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.upenn\.edu$|i', $email)) {
  // invalid email address
}
?>
[/code]
Link to comment
Share on other sites

If you also want to validate it's an email (so strings like "4895.upenn.edu384" will return false), try this:
[code]<?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 />";
}
}
?>[/code]

**Note- Haven't tested it.

Orio.

EDIT- obsidian got me :P
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.