| | #1 |
| Razibur Rahman Join Date: 2012 Location: Dhaka
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
|
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 |
| |
| | #2 |
| Warrior Member War Room Member Join Date: 2012
Posts: 24
Thanks: 0
Thanked 4 Times in 4 Posts
| |
| | |
| |
| | #3 |
| Active Warrior War Room Member Join Date: 2007 Location: New York City, NY, USA
Posts: 33
Thanks: 0
Thanked 17 Times in 12 Posts
|
Linux Journal has an excellent article on validating that a given e-mail address conforms to the RFC specification, check it out.
|
| |
| The Following User Says Thank You to LordKaT For This Useful Post: |
| | #4 |
| Software Product Creator War Room Member Join Date: 2012 Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5 |
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! |
| Recurring Proven SEO Business Model Rent Out Your (Local) Sites and YT vids Give you AD Funnel Super Power! ADConnect.io - Lower CPC. Sky-Rocket Conversions!! | |
| |
| The Following 2 Users Say Thank You to SteveSRS For This Useful Post: |
| | #5 | |
| Advanced Warrior War Room Member Join Date: 2011 Location: Brisbane, Australia
Posts: 886
Thanks: 76
Thanked 156 Times in 142 Posts
|
| |
|
Martin Platt martin-platt.com Stuck with earning commissions online? Get this get this uncensored affiliate marketing guide for free (sold as coaching for $4,997) | ||
| |
| | #6 |
| HyperActive Warrior War Room Member Join Date: 2012 Location: Ohio, USA
Posts: 139
Thanks: 8
Thanked 35 Times in 31 Posts
|
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: |
| | |
| |
| | #7 |
| Content Guru War Room Member Join Date: 2009 Location: Atlanta, GA
Posts: 1,392
Thanks: 48
Thanked 356 Times in 315 Posts
|
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. | |
| |
| | #8 |
| Active Warrior War Room Member Join Date: 2013 Location: pune
Posts: 32
Thanks: 6
Thanked 5 Times in 5 Posts
|
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."; } |
| | |
| |
| | #9 |
| Warrior Member War Room Member Join Date: 2007
Posts: 82
Thanks: 21
Thanked 10 Times in 10 Posts
|
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?
| |
| |
| | #10 |
| SKT Wordpress Themes War Room Member Join Date: 2013 Location: Nagpur
Posts: 65
Thanks: 5
Thanked 28 Times in 11 Posts
|
Hello Use PHP built in functions if(filter_var($mail, FILTER_VALIDATE_EMAIL)) { echo "Mail is valid!"; } |
| | |
| |
| | #11 |
| TNT Join Date: 2012 Location: florida
Posts: 65
Thanks: 19
Thanked 5 Times in 5 Posts
|
I use this in my script PHP Code: |
|
If everyone knew everything the world sure would be irritating
| |
| |
|
| Bookmarks |
| Tags |
| check, email, error, php, valid |
| |