TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 08-06-2008, 03:58 AM   #1 (permalink)
The Wanderer
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 11
Thanks: 0
Randy is on a distinguished road
Default 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..
__________________
Best Regards,
Randy Cram
Send a message via AIM to Randy Send a message via MSN to Randy Send a message via Yahoo to Randy
Randy is offline  
Reply With Quote
Old 08-06-2008, 11:26 AM   #2 (permalink)
The Frequenter
Advanced Programmer Top Contributor Good Samaritan 
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 469
Thanks: 26
sketchMedia is on a distinguished road
Default

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: 8 Practical PHP Regular Expressions
__________________

Last edited by sketchMedia : 08-06-2008 at 06:22 PM.
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:01 PM.

 
     

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