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

update sql when refresh - php
hi
I have made a table (attachement)

the users can update the sql database using + or x bu

How to submit a form to the same page?
I have a table containing information about books in my library and this table has the following col

Format timestamp from mysql
When I tried this:
Code: date("m/d/Y H:i A", $row['timestamp'])
I got 12/31/1969 18:

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

opening a window with after form submission
I know this this forum has nothing to do with JS, but i'm trying to use it with my php script.
<

Forms Authentication and Refresh at Login page
Hello, When I try to press the Login button in my webapplication at my login.aspx page nothing h

A WBS element with the name XXX already exists in version FREI_VERSION
Hi.
When I am trying to insert WBS element in a project, error occurs:

"A WBS eleme

Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

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