Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
Share
LinkBack Thread Tools
Old 02-17-2013, 09:28 AM   #1
Razibur Rahman
 
Join Date: Apr 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
Old 02-17-2013, 09:32 AM   #2
Warrior Member
War Room Member
 
Join Date: Dec 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
Old 02-17-2013, 10:02 AM   #3
HyperActive Warrior
War Room Member
 
Join Date: Jan 2007
Location: New York City, NY, USA
Posts: 120
Thanks: 0
Thanked 11 Times in 10 Posts
Social Networking View Member's Twitter Profile 
Contact Info
Send a message via AIM to LordKaT
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
Old 02-18-2013, 01:42 AM   #4
Software Product Creator
War Room Member
 
SteveSRS's Avatar
 
Join Date: May 2012
Location: NL & Peru & USA
Posts: 429
Blog Entries: 5
Thanks: 41
Thanked 146 Times in 83 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
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
Old 02-18-2013, 01:43 AM   #5
Advanced Warrior
War Room Member
 
MartinPlatt's Avatar
 
Join Date: Jul 2011
Location: Brisbane, Australia
Posts: 871
Thanks: 69
Thanked 143 Times in 132 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via MSN to MartinPlatt
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...

Affiliate links and templates are not allowed.
MartinPlatt is offline   Reply With Quote
Old 02-18-2013, 06:20 AM   #6
HyperActive Warrior
War Room Member
 
dwoods's Avatar
 
Join Date: Sep 2012
Location: Ohio, USA
Posts: 139
Thanks: 8
Thanked 35 Times in 31 Posts
Contact Info
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
Old 02-18-2013, 07:25 PM   #7
Content Guru
War Room Member
 
TheContentAuthority's Avatar
 
Join Date: Sep 2009
Location: Pittsburgh, PA US
Posts: 1,410
Thanks: 49
Thanked 360 Times in 320 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
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



We customize your blog, eBook, press release and backlink content with your message.

The Content Authority
TheContentAuthority is offline   Reply With Quote
Old 02-20-2013, 11:12 AM   #8
Active Warrior
War Room Member
 
ankur625's Avatar
 
Join Date: Feb 2013
Location: pune
Posts: 32
Thanks: 6
Thanked 5 Times in 5 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
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
Old 02-22-2013, 11:34 PM   #9
Warrior Member
War Room Member
 
Amirol's Avatar
 
Join Date: Sep 2007
Posts: 91
Thanks: 24
Thanked 11 Times in 11 Posts
Social Networking View Member's Twitter Profile 
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
Old 07-24-2013, 07:28 AM   #10
SKT Wordpress Themes
War Room Member
 
sktthemes's Avatar
 
Join Date: Jul 2013
Location: Nagpur
Posts: 63
Thanks: 4
Thanked 9 Times in 9 Posts
Social Networking View Member's Twitter Profile 
Contact Info
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
Old 07-25-2013, 02:26 PM   #11
TNT
 
otfromtot's Avatar
 
Join Date: Sep 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

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

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 07:03 AM.