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

FTP issues
Hi all,


I am currently facing some serious problems with a script and really need some ad

Edit MySQL Row Using PHP and HTML Form
Hello,

Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.

Character increment
Hi,

I am facing a scenario like above,but in my case i want to show up like Col A,Col B etc..

Schedule editor
Hi,

I have a question related to Schedule editor.
If we schedule a BLS for every 30

Web Host List
Here is a list of web hosts that offer PHP and MySQL. It is no where near a full list, but it is mos

pagination numbering pattern
Hello,

I have following code which works great for pagination. but i have small issue now.

Problem displaying "scraped" XML data
I'm basicly having trouble displaying XML data scraped from an URL using cURL.

What the code

how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?

Need help to modify php ELSE code
I'm trying to find a way to have the php code display a message if there is no inventory listed in t

Find occurences of unicode characters in string
I need to prohibit filenames with everything but English characters and numbers but regexp and strin

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