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

PHP Array quick help
I need

$_SESSION{'username'} to be like this:


if $_SESSION['username'] = "gay

Table sorting
Hi,

I'm trying to modify the following in order to make the output table sorted alphabeticall

Appending GET data with form submition
Okay, what I'm trying to do is to use a form to append an already existing GET data string.

I

Pulling out some result data from MYSQL
Hey Guys,

I've built a PHP page that has a for just imagine something like registration form

Most basic form question ever?
Hello,

I want to use this snippet to make sure the fields in a form are ok before processing

PHP, Arrays & A Lot Of Confusion
I've been doing basic PHP work on sites for a few years now, but I've never been tempted to learn ho

selectbox+database connection retrive problem
Code: [Select]
<tr>
<th align="left" scope="c

add text and number image
hi guys ..

ok see i want the user to add their name and pick a number then click get it and i

md5 is it unique
I know this is most likely one of many simple questions that can be found semi easily. But I'm press

Storing user data help?
Hey Guys,

I'm not use if this question is to broad but I can always give you more informatio

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