TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   some help (http://www.talkphp.com/absolute-beginners/3216-some-help.html)

Randy 08-06-2008 02:58 AM

some help
 
alright well first off this may be in the wrong section but i am not quite sure what language i would use and im using some PHP so i posted this here.

I am working on a contact form and i need some help preventing illegal characters such as "`" "!" "#" "$" "%" "(" and so on.

I was told to use regex by Andrew R but i tried sitepoint, google, pixel2life, other freelance forms and all sorts of stuff and seriously got nothing..

sketchMedia 08-06-2008 10:26 AM

For a simple alpha-numeric check you can use:
PHP Code:

if(preg_match('/[^a-z0-9\s]/i'$szInput))//can also be '/[^a-z\d\s]/i'
{
    die(
'illegal chars found');


That script should also ignore white space and is case insensitive, just remove '\s' and the 'i' at the end if you want to remove these features ('\s' being White space and 'I' being case sensitivity)


This post may be of help to you: http://www.talkphp.com/advanced-php-...pressions.html


All times are GMT. The time now is 06:43 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0