Checking if..

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
User avatar
Howey
Forum Newbie
Posts: 17
Joined: Sun May 16, 2004 5:48 pm
Location: Middle of no where

Checking if..

Post by Howey »

Hello I have multiple forms around my site and I have to check all to make sure there isnt numbers, spaces, special characters, ect. I know it has to deal with ereg and I have seen and tried to understand the information found on http://www.php.net/ereg but I still just cant seem to understand it well enough to make the function let alone make different versions of it. If anyone has maybe a link to a good tutorial on it or maybe...a short description how it should be set up and what I should replace would be great.
Thanks in advance
Howey
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The PHP ctype functions might be of more use here, and they are easier to use than regex ;).
User avatar
Howey
Forum Newbie
Posts: 17
Joined: Sun May 16, 2004 5:48 pm
Location: Middle of no where

Post by Howey »

Thank you I will read up on that asap :)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

hello,

being an regEx person, I would use:

Code: Select all

<?php
if (!ereg("^[_a-zA-Z0-9-]+$", $name)) {   
die (ERROR);
}
?>
Post Reply