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

Accessing element of object array
Hello

My object looks like this:


Array ( [0] => User Object ( [id] =>

php call servlet
I have done a php backup application .
So there is a form that user pick some files to zip and d

Image resize
Hi again fellers

I managed to sort out the issues with the folder,

Final hurdle is th

If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.

i have this c

get multiple rows
Hi I want to get multiple rows from a db

I am using this for the db query
Code: public

Entering Data Problem
Code: $result = mysql_query("SELECT * FROM flights");
while ($row = mysql_fetch_array($

Xml parsing
I need a suggestion about parsing xml with multiply parts like pervious...
i.e. different device

private constructor
Hello,

Can we create a constructor as private? If yes, what is the use of it? If no, why can'

code help - pagination
Hi all, I have this code, basically a user logs into my site and they get this page.

The pro

How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan

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