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!
Simply problem but I can't find exactly what I want.
I have an HTML form that puts values from the form into a file. For a few of these values I want it to only accept letters and numbers (no spaces) as well as no symbols. How do I do it?
regular expressions. We have a board dedicated to just that, but before you ask for the solution, try to figure it out yourself by reading the stickies we've got in that board first.
hang just realised that you might want to filter out all the non-alphanumeric characters rather than test for them. In which case you need to use this (this is a regular expression):
Thanks for the help. ctype_alnum seems to work the way I want it. Now, however, in another field I want it to allow letters, numbers and spaces. Like ctype_alnum, I'd like to be able to test this rather than replacing values (regular expressions don't seem to test, they just replace) because I want to put this into an if() statement.