bilis_money Posted August 13, 2006 Share Posted August 13, 2006 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted August 13, 2006 Share Posted August 13, 2006 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] Quote Link to comment Share on other sites More sharing options...
effigy Posted August 13, 2006 Share Posted August 13, 2006 [tt]/^[a-zA-Z0-9]+$/[/tt] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.