Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Stripping harmful tags [newbie]
I found what looks to be a useful snippet of php code to check for
harmful tags and strip them from a posted form arrayt.

However, it doesn't "work". Ir doesn't provide any useful error
messages, but, it also doesn't strip the tags.

Looking it over, it appears to step through each element in the array
and strip the tags, but, I don't see how it actually restores them to
the array once they're stripped.

The link where I originally found the snipped is in the comments.

Jennifer

////////////////////////////////
// This loop removed "dangerous" characters from the posted data
// and puts backslashes in front of characters that might cause
// problems in the database.
// From: http://www.awtrey.com/support/dbeweb/php.php
// Strip tags and escapeshellcmd in Beginning book (pg. 486)
////////////////////////////////
for(reset($HTTP_POST_VARS);
$key=key($HTTP_POST_VARS);
next($HTTP_POST_VARS)) {
$this = addslashes($HTTP_POST_VARS[$key]);
$this = strtr($this, ">", " ");
$this = strtr($this, "<", " ");
$this = strtr($this, "|", " ");
$this = strip_tags($this);
$this = escapeshellcmd($this);
$$key = $this;
}

Report this thread to moderator Post Follow-up to this message
Old Post
Gwen Morse
11-15-04 08:57 PM


Re: Stripping harmful tags [newbie]
Hi

This code gets input from $HTTP_POST_VARS but puts output in corresponding
variables, eg. takes from $HTTP_POST_VARS['some_var'] and puts in $some_var.
Better way to do this task is to use functions like mysql_escape_string or
mysql_real_escape_string (for MySQL, other databases usually have different
special chars, or they are escaped differently, and they may provide paramet
ers,
which are better and safer than direct embeding data in SQL statements) and
htmlspecialchars (I suggest using this when displaing user provided data, no
t when
storing it).

Hilarion



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
11-15-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:31 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.