Securing a user input - need some confirmation


Posted on 16th Feb 2014 07:03 pm by admin

Hello All,

I am in the process of recoding a large proportion of an e-commerce site, one of the problems is that there are a few security issues floating around.

Did you know?Explore Trending and Topic pages for more stories like this.
I have a search box which was originally unprotected against XSS, I was easily able to execute JavaScript and force the system to echo out HTML *holds head in hands*.

I am using this code:

$term=preg_replace('/[^a-zA-Z0-9s]/', "", $term);

...to remove any non-alphanumeric characters (excluding spaces), I am thinking because this will strip out any characters like ', ", <, >, /, = etc, it should make my script safe again.

Can you confirm this, or is there something that I am missing?


Many thanks
No comments posted yet

Your Answer:

Login to answer
217 Like 28 Dislike
Previous forums Next forums
Other forums

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

IIS7 and getimagesize() problem
I have just discovered after hrs of trying to fix a problem where it's coming from. It's to do with

CURL question
i am wondering if it's possible to use multi curl with login something like

login once to web

Pagination
Hi All,

I think I'm finally getting somewhere with pagination!

I can now submit a quer

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

PHP friend keyword equivalent
is there a PHP equivalent for the C++ friend keyword?

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f

post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu

Day of week
I am using PHP version 5.0.5
I have a varaible ($DATE (date format yyyy-mm-dd)) that is being inc

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash