Page 1 of 1

Checking if..

Posted: Mon Jun 21, 2004 5:04 pm
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

Posted: Mon Jun 21, 2004 5:06 pm
by markl999
The PHP ctype functions might be of more use here, and they are easier to use than regex ;).

Posted: Mon Jun 21, 2004 5:16 pm
by Howey
Thank you I will read up on that asap :)

Posted: Mon Jun 21, 2004 6:11 pm
by tim
hello,

being an regEx person, I would use:

Code: Select all

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