#1 (permalink)  
Old 08-21-2006, 11:49 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,437
PHP Form Validation Tutorial

I have a few suggestions for the PHP form validation tutorial Till wrote a while back, and Allen just recently discovered for himself when having a problem with form validation.

I checked out the tutorial for myself to see what I might learn for myself.

I came across two things I would like to suggest for the tutorial.

1) Check the character set for the tutorial (and this may be true throughout the site, but I only noticed it on this tutorial, so far). For some of us, we see strange characters rather than the code that should be displayed.



2) Can you please add some information about validating email addresses? I would be willing to bet that the majority of forms request the user to enter an email address, and it would be nice to see some information on how to validate those.
I found the information I was looking for in a tutorial on another site, but it honestly was not as easy to find as you might expect. It would be great to find that information here on HTMLCenter.

BTW - For those interested, this is a snippet of the code I found in this tutorial:
PHP Code:
 if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]"$email_input)) 
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote

  #2 (permalink)  
Old 08-23-2006, 05:04 AM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
Quote:
Originally Posted by curtiss
1) Check the character set for the tutorial (and this may be true throughout the site, but I only noticed it on this tutorial, so far). For some of us, we see strange characters rather than the code that should be displayed.
Good catch. I fixed those.

Quote:
Originally Posted by curtiss
2) Can you please add some information about validating email addresses? I would be willing to bet that the majority of forms request the user to enter an email address, and it would be nice to see some information on how to validate those.
I found the information I was looking for in a tutorial on another site, but it honestly was not as easy to find as you might expect. It would be great to find that information here on HTMLCenter.
The regex you posted does not really validate - but you are correct, I'll add something.

Reply With Quote
  #3 (permalink)  
Old 08-25-2006, 11:28 AM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
The sequal is online!
http://www.htmlcenter.com/tutorials/...s.cfm/189/PHP/



What do you think?
Reply With Quote
  #4 (permalink)  
Old 08-26-2006, 04:11 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,437
Thank you very much. It works a treat.

However, I think there's one thing that you might want to clarify in your tutorial.

Where you say:
Quote:
Following the "@" we basically allow the same, but force an extension in the end. And the extension on email addresses are supposed to be characters only, with a minimum length of two characters and maxmimum length of (currently) four.
you may want to add a little note about the fact that your current script will only treat the "uk" in co.uk extensions (and similar domain extensions) as the extension, and that the "co" will be considered part of the domain itself.

I hope I made sense when I explained that.

I have to admit that when I first looked at your code, I thought that you had neglected to allow email addresses from domains like example.co.uk, but I realized that only the "uk" part of the extension would be evaluated as an extension.
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #5 (permalink)  
Old 08-26-2006, 05:22 PM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
Quote:
Originally Posted by curtiss
you may want to add a little note about the fact that your current script will only treat the "uk" in co.uk extensions (and similar domain extensions) as the extension, and that the "co" will be considered part of the domain itself.
Yeah, well, the sub domains are not so important. To actually validate TLDs and so on, you would need to keep a list of available TLDs. It always depends on how critical getting the email address is and what you want to do with it in the end.

This basically stops the "me@email" submissions that people like to do, and if you plan to use the email address to address further communication to the user the "double-opt-in" method I (side)noted is the way to use.

My two Eurocents!
Reply With Quote
  #6 (permalink)  
Old 09-04-2007, 07:25 PM
Registered User
 
Join Date: Sep 2007
Posts: 1
[quote=Till;10687]The sequal is online!
http://www.htmlcenter.com/tutorials/...s.cfm/189/PHP/

sequal? oh well...

^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$
so _@-&aa would match, or even -_-_-?_-_@-!-!-.org, but not admin@smithsonian.museum.
Shouldn't all periods be escaped, so \., not just .?
And maybe something to require the parts to start with an alphanumeric character.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
auto submit a form? possible? Allen Programming and Scripting 1 08-04-2006 03:14 AM
A Function for a PHP Form Validating kenwvs Programming and Scripting 5 07-12-2006 05:13 PM
Setting Values For Form Elements With Unconventional Names curtiss Programming and Scripting 2 06-04-2006 09:28 PM
Obtaining a Form Elements Index by Name curtiss Programming and Scripting 3 05-02-2006 11:25 AM
passing information from 1 form to another amanxman Programming and Scripting 3 04-12-2006 04:59 PM


All times are GMT -5. The time now is 01:53 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter