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: 12
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 Send a message via Skype™ 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
eCommerce + mCommerce
War Room Member
 
SteveSRS's Avatar
 
Join Date: May 2012
Location: NL & Peru & USA
Posts: 335
Blog Entries: 2
Thanks: 24
Thanked 73 Times in 63 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?

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!

Public Beta Relased: 100% Free SRS Easy Android Root software launch. Mainly Samsung but also HTC, ZTE and more. 1-Click Android Root and Unroot!

[SOOOON]
My new -ALL FREE- Premium eBook website
SteveSRS is online now   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: 806
Thanks: 65
Thanked 123 Times in 114 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 Send a message via Skype™ 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...

MartinPlatt is online now   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: 140
Thanks: 8
Thanked 35 Times in 31 Posts
Contact Info
Send a message via Skype™ to dwoods
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: 994
Thanks: 48
Thanked 242 Times in 221 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
Send a message via Skype™ to TheContentAuthority
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: 31
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: 89
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.

Amirol 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 12:40 AM.