![]() | ![]() | ||||||||
| | #1 |
| Razibur Rahman Join Date: Apr 2012 Location: Dhaka
Posts: 12
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: Dec 2012
Posts: 24
Thanks: 0
Thanked 4 Times in 4 Posts
| |
| | |
| | |
| | #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
|
Linux Journal has an excellent article on validating that a given e-mail address conforms to the RFC specification, check it out.
|
| | |
| | #4 |
| eCommerce + mCommerce War Room Member Join Date: May 2012 Location: NL & Peru & USA
Posts: 335
Blog Entries: 2 Thanks: 24
Thanked 73 Times in 63 Posts
|
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 | |
| | |
| | #5 | |
| Advanced Warrior War Room Member Join Date: Jul 2011 Location: Brisbane, Australia
Posts: 806
Thanks: 65
Thanked 123 Times in 114 Posts
| Quote:
| |
| | ||
| | |
| | #6 |
| HyperActive Warrior War Room Member Join Date: Sep 2012 Location: Ohio, USA
Posts: 140
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: Sep 2009 Location: Pittsburgh, PA US
Posts: 994
Thanks: 48
Thanked 242 Times in 221 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 |
![]() We customize your blog, eBook, press release and backlink content with your message. The Content Authority | |
| | |
| | #8 |
| Active Warrior War Room Member Join Date: Feb 2013 Location: pune
Posts: 31
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: Sep 2007
Posts: 89
Thanks: 24
Thanked 11 Times in 11 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. |
| | |
| | |
![]() |
|
| Bookmarks |
| Tags |
| check, email, error, php, valid |
| Thread Tools | |
| |
![]() |