Quote:
Originally Posted by Boofo
How do you check to make sure that a variable only allows 1 letter or number? Here is the variable I am using in the php file:
Code:
$vbulletin->GPC['letter']
I want to do a check to make sure only one letter or number is entered. Right now you can enter anything for it.
|
Untested but it should work
PHP Code:
if ((strlen($vbulletin->GPC['letter']) == 1) && preg_match('/^[a-zA-Z0-9]+$/', $vbulletin->GPC['letter']))
{
//good value processing
} else {
//error code here
}
First part makes sure it's only 1 character long, second part makes sure it's only letters and numbers