Jump to content

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


bilis_money

Recommended Posts

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.



Link to comment
https://forums.phpfreaks.com/topic/17374-restricting-input-a-z-and-a-z-and-0-9/
Share on other sites

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
[code=php:0]
if (!preg_match("/[a-z0-9]$/i", $topic_tmp))
{
    die ("incorrect name.");
}
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.