How Can I Verify An Email Address That Is Entered On My Web Form? |
||
Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.
In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.
Zymic Webmaster Forums Web Design & Development General Web Design Discussion |
||
![]() |
How Can I Verify An Email Address That Is Entered On My Web Form? |
||
Sep 30 2009, 08:45 PM
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 2 Joined: 30-September 09 Member No.: 112,112 |
Sometime my visitors mistype their email address. I want to verify it so their message is not delivered until the email field is ok. Something like checking for @ character, etc.
|
|
|
Oct 1 2009, 05:48 AM
Post
#2
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 1-October 09 Member No.: 112,166 |
You can use another error output method but that generally works for me.
CODE $errors = array();
$regex = "/^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+.[a-z]{2,}$/i"; if(!preg_match($regex, $email_field)) { $errors[] = "E-mail is not in correct format!<br />"; } |
|
|
Oct 1 2009, 11:10 AM
Post
#3
|
|
![]() Outrageously Uber Ninja ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrators Posts: 2,831 Joined: 11-March 07 From: UK Member No.: 9 |
PHP5 comes with a fantastic little filter library:
CODE if(filter_var($email, FILTER_VALIDATE_EMAIL)) { // Email format is correct } If you're not on Zymic hosting you can extend the check to start a smtp session with the domain's mail exchange servers and check the email address actually exists. This method isn't full proof if someone sets their MX records to point to a mailserver which has been setup as a relay. Email verification is the best method to ensure the mailbox actually exists. |
|
|
Oct 2 2009, 09:35 AM
Post
#4
|
|
|
Newbie ![]() Group: Members Posts: 2 Joined: 30-September 09 Member No.: 112,112 |
PHP5 comes with a fantastic little filter library: CODE if(filter_var($email, FILTER_VALIDATE_EMAIL)) { // Email format is correct } If you're not on Zymic hosting you can extend the check to start a smtp session with the domain's mail exchange servers and check the email address actually exists. This method isn't full proof if someone sets their MX records to point to a mailserver which has been setup as a relay. Email verification is the best method to ensure the mailbox actually exists. To my surprise, my free hosting service does not have PHP5 , or even worst, any version of PHP. So my only solution is to use a remotely hosted form service, like http://www.123contactform.com or http://www.kontactr.com |
|
|
Oct 2 2009, 10:28 AM
Post
#5
|
|
![]() Outrageously Uber Ninja ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrators Posts: 2,831 Joined: 11-March 07 From: UK Member No.: 9 |
To my surprise, my free hosting service does not have PHP5 , or even worst, any version of PHP. So my only solution is to use a remotely hosted form service, like http://www.123contactform.com or http://www.kontactr.com Zymic's free hosting offers php5; However we don't provide outgoing connections so SMTP checks can't be performed, filter exists however and mail() can be enabled for a one off $10 charge. |
|
|
Sep 29 2011, 07:00 AM
Post
#6
|
|
|
Member ![]() ![]() Group: Members Posts: 30 Joined: 26-September 11 Member No.: 210,615 |
Very strange request in an art forum from a first time poster. BUT, in the interest of answering the question:
Attach an onClick event to your submit button, so that it doesn't submit the form until a predetermined function has processed. The function should be written in Javascript. To show you how easy such a task is, I Googled "javascript validate email", and the very first result was this site: http://www.codetoad.com/javascript/is_valid_email.asp That should do what you need, magical robot...and it doesn't cost a dime. |
|
|
![]() |
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users) |
||
| 0 Members: | ||
Forum Jump |
||
| Lo-Fi Version | Time is now: 19th June 2013 - 10:37 PM |