ShugNiggurath
Technical User
Hi,
I have the following code:
$sec is a variable passed in the URL that I want to make sure is only lowercase letters or underscore, the above code fails any variable passed in the URL whether valid or not, and if I take out the !NOT operator, the reverse happens.
I've also tried the following versions:
and also without the underscores while testing.
I just can't see what I'm doing wrong. A pint in it for anyone who can help!
Cheers in advance,
Hugh
I have the following code:
Code:
if (!ereg('^[a-z_]$', '$sec')) {
// failed url validation
echo "You are not allowed to access this page in that way";
} else {
$sec is a variable passed in the URL that I want to make sure is only lowercase letters or underscore, the above code fails any variable passed in the URL whether valid or not, and if I take out the !NOT operator, the reverse happens.
I've also tried the following versions:
Code:
if (!ereg('^[a-z_]+$', '$sec')) {
// failed url validation
echo "You are not allowed to access this page in that way";
} else {
if (!ereg('[a-z_]', '$sec')) {
// failed url validation
echo "You are not allowed to access this page in that way";
} else {
and also without the underscores while testing.
I just can't see what I'm doing wrong. A pint in it for anyone who can help!
Cheers in advance,
Hugh