How can I check that a data value is alphanumeric?
However if you don't want to get involved with those or find them confusing, as usual with PHP there is a function lurking around to help you achieve your desired result.
You can easily validate specific to the curernt locale setting with the ctype_alpha function, one of the character type functions added to PHP in version 4.3 which works like this:
<?php
$formvalue = "am I alphanumeric or not";
if(ctype_alpha($formvalue)) { echo "Yes I am!"; } else { echo "No I'm not!"; }
?>
In this case printing "No I'm not!" because $formvalue contains spaces.
Comment on this Question and Answer >>>
ASK A QUESTION
More forms PHP Questions
How do I remove escape characters from data?I am taking over a position from another programmer, and want to change some php code, but part of it has me baffled. The code creates a form and after it is filled, the client wants it to go to a separate thank you page – right now, it re-uses the for
how to avoid the refresh or goback to submit the post values in database
How can I access information sent through POST on a form?
How do I escape data that is going into a database?
