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

distinct rows
Hi
version 10.2.0.3

I have a query output something like the following

ID

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

include
Hi I have this way of licensing my PHP application, and I want to know if you guys can answer some q

generate seo frienly url from a text like wordpress
Convert: "åäö" to "aao", "space" to "-", "!?&q

Set Categories
I am creating a submission form for somebody to come in and submit products. These products are sep

ereg_replace()
Basically what i need to do is

$title = "This Suck's"

$striped = ereg_repl

Save cookie to DB
I'm working on a pixel tracking script for an incentive website and I need to use an ASP script to s

losing session vars when arriving from an email link
Hi,

I've got a confirmation script made that sends an email with a link for a user to confirm

Navigation include for all site directories
Hi,

I need a navigation include that can deal with directories at different levels on a site.

Query output more than expected
$query=mysql_query("SELECT * FROM players, communities, divisions WHERE dob BETWEEN '{$start_da

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