Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] Checking user's name input.


Checking user's name input.

Closed Thread
  #1 (permalink)  
Old 11-30-09, 06:45 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
Checking user's name input.

Hello,

I'm having a problem checking user input with PHP. Now I have this code that checks the users firstname to make sure its valid:

PHP Code:

if(!preg_match('/^[A-Za-z]+$/'$_POST['firstname'])) {

    
$error[] = array("message" => "First name can only contain alphabetical characters""element" => "firstname");

Now this checks that it only contains A-Z which is fine if some ones name only contains A-Z. In some cases peoples names contain other characters. For example the name Zoë. If I pass Zoë through this code it fails because of the ë character.

How would I modify the code to allow for these other charcters you would find in peoples names?

Thanks

Scott
  #2 (permalink)  
Old 11-30-09, 11:32 AM
scott2500uk's Avatar
scott2500uk scott2500uk is offline
Coding Addict
 
Join Date: Apr 2006
Posts: 275
Thanks: 2
Thanked 2 Times in 2 Posts
NVM I've found the solution to my problem.

PHP Code:

if(!preg_match('/^(\p{L}|\p{Lo})+$/u'$_POST['firstname'])) {

    
$error[] = array("message" => "First name can only contain alphabetical characters""element" => "firstname");

Scott
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve the users input data from PlaceHolder? Elaine ASP.NET 3 12-09-06 11:32 AM
Select users from database zoliky Database 2 08-14-06 04:15 PM
best way to log in users, and keep them logged in nassau PHP 15 01-16-06 05:13 PM
Checking how many users connected to http / ftp? zenonflare PHP 3 06-11-05 05:16 PM
2 flash websites for sale metamorph General Advertisements 5 01-09-05 10:03 PM


All times are GMT -5. The time now is 08:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.