Freelancer.com

Go Back   Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming
Register Blogs Social Groups Advertise with usHelp Desk

Reply
LinkBack Thread Tools
Unread 17th February 2013, 10:28 AM   #1
Razibur Rahman
 
Join Date: 2012
Location: Dhaka
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Default PHP.. How to check valid email error?

Hi, I can check field, number of character error. But I don't know how to check valid email error or website error..

I mean if user submit invalid email address or website like without "@" and ".com .net" then script will not run further...

How do I create this script? Please help

thanks
rrahman is offline   Reply With Quote
Unread 17th February 2013, 10:32 AM   #2
Warrior Member
War Room Member
 
Join Date: 2012
Posts: 24
Thanks: 0
Thanked 4 Times in 4 Posts
Default Re: PHP.. How to check valid email error?

best validator

Quality Ties at Affordable Prices
Men's Tie Deals
Promo code WARRIOR = 10% off!
nathan1 is offline   Reply With Quote
Unread 17th February 2013, 11:02 AM   #3
HyperActive Warrior
War Room Member
 
Join Date: 2007
Location: New York City, NY, USA
Posts: 120
Thanks: 0
Thanked 11 Times in 10 Posts
Default Re: PHP.. How to check valid email error?

Linux Journal has an excellent article on validating that a given e-mail address conforms to the RFC specification, check it out.
LordKaT is offline   Reply With Quote
Unread 18th February 2013, 02:42 AM   #4
Software Product Creator
War Room Member
 
SteveSRS's Avatar
 
Join Date: 2012
Location: NL & Peru & USA
Posts: 456
Blog Entries: 5
Thanks: 44
Thanked 153 Times in 89 Posts
Default Re: PHP.. How to check valid email error?

Hi,

That is a lot of coding in the article above for something that can be done way easier:
PHP: Validation - Manual

For php questions like this always do a search on php.net almost always helps!

SteveSRS is offline   Reply With Quote
Unread 18th February 2013, 02:43 AM   #5
Advanced Warrior
War Room Member
 
MartinPlatt's Avatar
 
Join Date: 2011
Location: Brisbane, Australia
Posts: 874
Thanks: 70
Thanked 147 Times in 136 Posts
Default Re: PHP.. How to check valid email error?

Quote:
Originally Posted by rrahman View Post
Hi, I can check field, number of character error. But I don't know how to check valid email error or website error..

I mean if user submit invalid email address or website like without "@" and ".com .net" then script will not run further...

How do I create this script? Please help

thanks
You should be able to check it using a regular expression. Should be plenty of examples on Google...
MartinPlatt is offline   Reply With Quote
Unread 18th February 2013, 07:20 AM   #6
HyperActive Warrior
War Room Member
 
dwoods's Avatar
 
Join Date: 2012
Location: Ohio, USA
Posts: 139
Thanks: 8
Thanked 35 Times in 31 Posts
Default Re: PHP.. How to check valid email error?

I've used many regex's over the years -- some strict some not; but my current method for validating email with PHP is using the PHP's pre-baked filter_var()

PHP Code:
//best way is with php5 filters: 
if(!filter_var(, FILTER_VALIDATE_EMAIL)){
    return 
false;


Need a way to drive traffic to your new site?
-- Check out HelpMyHits.com!
dwoods is offline   Reply With Quote
Unread 18th February 2013, 08:25 PM   #7
Content Guru
War Room Member
 
TheContentAuthority's Avatar
 
Join Date: 2009
Location: Atlanta, GA
Posts: 1,403
Thanks: 49
Thanked 363 Times in 322 Posts
Default Re: PHP.. How to check valid email error?

rrahman

You could use this,

//email validations
if(!$this->validate_email($_POST['email']))
{
$this->add_error("Please provide a valid email address");
$ret = false;
}

With this function
function validate_email($email)
{
return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);
}

Hope that helps,

Shawn

Outsource to the experts...

We customize your Blog, eBook, Press Release and Sale Copy content with your message.

TheContentAuthority is offline   Reply With Quote
Unread 20th February 2013, 12:12 PM   #8
Active Warrior
War Room Member
 
ankur625's Avatar
 
Join Date: 2013
Location: pune
Posts: 33
Thanks: 6
Thanked 5 Times in 5 Posts
Default Re: PHP.. How to check valid email error?

use this,

if(!empty($_POST['email'])) {
if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_POST['email'])){
$errors = "Please enter a valid email address.";
} else { $email = mysql_real_escape_string(trim($_POST['email'])); }
} else { $errors[] = "You forgot to enter email address."; }

ankur625 is offline   Reply With Quote
Unread 23rd February 2013, 12:34 AM   #9
Warrior Member
War Room Member
 
Amirol's Avatar
 
Join Date: 2007
Posts: 91
Thanks: 24
Thanked 11 Times in 11 Posts
Default Re: PHP.. How to check valid email error?

Hi,

First make sure your input type is email.

<input type="email" size="30" value="" />

Then for 2nd layer validation, just use the code provided by dwoods.

Need help with PHP and Laravel?
Amirol is offline   Reply With Quote
Unread 24th July 2013, 07:28 AM   #10
SKT Wordpress Themes
War Room Member
 
sktthemes's Avatar
 
Join Date: 2013
Location: Nagpur
Posts: 65
Thanks: 4
Thanked 9 Times in 9 Posts
Default Re: PHP.. How to check valid email error?

Hello
Use PHP built in functions

if(filter_var($mail, FILTER_VALIDATE_EMAIL))
{
echo "Mail is valid!";
}

sktthemes is offline   Reply With Quote
Unread 25th July 2013, 02:26 PM   #11
TNT
 
otfromtot's Avatar
 
Join Date: 2012
Location: florida
Posts: 65
Thanks: 19
Thanked 5 Times in 5 Posts
Default Re: PHP.. How to check valid email error?

I use this in my script
PHP Code:
 = array(
    
'first_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'last_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'phone' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[0-9-]{7,20}$/i'),
    ),
    
'email' => FILTER_VALIDATE_EMAIL,
); 

If everyone knew everything the world sure would be irritating
otfromtot is offline   Reply With Quote
Reply

  Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming

Bookmarks

Tags
check, email, error, php, valid

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:55 AM.