Jump to content

Archived

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

bilis_money

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

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.



Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.