News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

WebProNews.com:
Form Checking - Verifying Name Using PHP Ereg
June 23, 2006 @ 07:40:01

On WebProNews.com, there's a brief tutorial on using regular expressions, specifically for filtering "names" entered by users.

One important use of Regular Expressions (Regex) is to verify fields submitted via a form. In this article, we attempt to write an expression that is able to verify the user's first name, middle name, last name or just names in general.

The expression should allow names such as "Mary", "Mr. James Smith" and "Mrs O'Shea" for example. So the challenge here is to allow spaces, periods and single quotation marks in the name field and reject any other characters.

Their examples use the preg_* functions in PHP to work, first looking for any invalid characters in the string(s), then amending it to ensure that there aren't any numbers involved either. The few lines of code it takes are included as well.

0 comments voice your opinion now!
regular expression form checking verify preg regular expression form checking verify preg


blog comments powered by Disqus

Similar Posts

JellyandCustard.com: Regular Expressions in PHP

Henrik Bjørnskov's Blog: Symfony2: Add Cross Site Request Forgery protection to login forms

DevShed: Using Abstract Factory Classes in PHP 5 to Work with Online Forms

Jonnay\'s Blog: Introducing BunnyRegex - easy regular expressions, and mini-languages inside of PHP.

Sanisoft Blog: Radio button issues while migrating from cakePHP-1.2alpha app to 1.2prebeta


Community Events





Don't see your event here?
Let us know!


interview laravel language series project community wordpress configure bugfix developer framework threedevsandamaybe introduction release api podcast list application code library

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework