checking for a space in a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

checking for a space in a string

Post by hame22 »

Hi

I want to prevent my users signing up to my site with a username that includes a space in it e.g 'name surname' should not be allowed only 'namesurname' or 'name_surname'.

How could I validate that an entered username does not include any spaces and return an error if it is unvalid?

thanks in advance
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

strpos() can be used to let you know if there are any spaces

Mac
Post Reply