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

need help in php variable
i have a php variable on one page
Code: [Select]$lastId = mysql_insert_id($db);
echo $lastId;<

Rand() help needed
Hi all,

Can someone explain and give me a quick example of how I would go about this?

Open/Close Links in Php
Hello, Hoping someone can inform me how I can get PHP to automatically open a set of links in a new

Firewall / visited websites logger
Hi. I have a firewall implementation and I want to log all the websites visited on the machine. S

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

i need help with php header and footer
I have designed a header and footer for my site and they seem to be ok when they are running individ

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

gettext translates ALWAYS?
I'm using gettext with the new version of XAMPP (5.3.0) on Windows Seven RTM (build 7600)
gettext

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

Varible in trigger - refering to correct schema
Hello

Im having some issues with my trigger.
What I want to do is call opon a differ

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