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
| SitePoint Sponsor |
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
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.
Bankruptcy office in USA... clients of all nationalities... predominately US, Russian, and Spanish/Mexican names.


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.
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
Thanks to all for the quick response ...
Closed!
@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
Thanks so much ... it's amazing how much I've learned from you'all ...
Bookmarks