Jump to content


Photo

restricting input? [a-z] and [A-Z] and [0-9]


  • Please log in to reply
2 replies to this topic

#1 bilis_money

bilis_money
  • Members
  • PipPipPip
  • Advanced Member
  • 621 posts

Posted 13 August 2006 - 01:07 AM

i'm planning to restrict user input.
I want only from character a-z, A-Z, and 0-9.

let say i have  a TEXT BOX with a name='topic',
and $topic_tmp = $_POST['topic'];

now i want $topic to accept the allowed character only how?
How could i do this on REGEX properly?


thanks PHP geeks in advance.





#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 13 August 2006 - 05:07 AM

Lolz most people dont take the term geeks in a nice sense....  Anyways, I'm no regex expert (just starting messin with it today) but you could use something like
if (!preg_match("/[a-z0-9]$/i", $topic_tmp))
{
    die ("incorrect name.");
}

Why doesn't anyone ever say hi, hey, or whad up world?

#3 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 13 August 2006 - 04:32 PM

/^[a-zA-Z0-9]+$/
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users