E-Mail Text Field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RZKG23
Forum Newbie
Posts: 1
Joined: Tue Nov 26, 2002 2:10 pm

E-Mail Text Field

Post by RZKG23 »

Hello,
I have an e-mail text field on a form. I want to add a function to my PHP Formmail processor that requires the e-mail address to include an "@" and a "." How do I do this/
Ryan
RySk8er30@aol.com
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

Post by BigE »

You will probably want to use REGEX for e-mail validation. But if you just want to check for the @ symbol and a peroid, use strstr() php.net/strstr Hope that helps.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you check in the documentation for the regular expressions there are a few versions of e-mail validation in the user comments:
http://www.php.net/manual/en/function.preg-match.php
http://www.php.net/manual/en/function.eregi.php

Mac
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

Try to use a pease of this:



(!preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.([a-zA-Z]{2,3})$/"))



Greathings Skywalker
Post Reply