SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Apr 23, 2009, 16:27 #1
- Join Date
- Apr 2009
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Newbee - help with validating last name to allow apostrophe
newbee needs a boost in how to validate a last name like O'Neal or O'Brien to allow the apostrophe to included?
That's all, folks Thanks
-
Apr 23, 2009, 16:55 #2
One important thing to consider first - is it possible that a user will enter non-english characters?
If it's only for English letters and apostrophies, then its very easy.
-
Apr 23, 2009, 17:10 #3
- Join Date
- Apr 2009
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bankruptcy office in USA... clients of all nationalities... predominately US, Russian, and Spanish/Mexican names.
-
Apr 24, 2009, 05:28 #4
- Join Date
- Apr 2009
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Validated as in "Able to put this in the Database"? If that's the case, parameterize your SQL, and you'll be good to go.
-
Apr 24, 2009, 05:36 #5
Since court filings use English letters only, you can use this to test for valid name:
if(preg_match("/[^a-zA-Z\s'-]+/", $string)){
exit('BAD');
}
// continue your script
-
Apr 24, 2009, 10:35 #6
- Join Date
- Apr 2009
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks to all for the quick response ...
Closed!
-
Apr 24, 2009, 10:59 #7
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
@Sharedlog.com, are you stating that foreign letters are invalid?
You shouldn't disallow those letters, it's wrong to do so. What about people's names, or names of a foreign language?
Instead, use MySQL_Real_Escape_String to allow the apostrophe etc in the name (You should do this to all MySQL input anyway unless you are using a library like PDO which doesn't require it). Then make sure you're using a character encoding which supports a vast range of characters, such as UTF-8 or UTF-16.
That way you allow input in without appearing unprofessional - and when dealing with court cases, being unprofessional and changing peoples' names so that they work with your broken system could be enough to bring a real court case upon your site.Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Apr 24, 2009, 12:09 #8
-
Apr 24, 2009, 12:21 #9
- Join Date
- Apr 2009
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks so much ... it's amazing how much I've learned from you'all ...
Bookmarks