TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack (1) Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-23-2007, 11:45 PM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
The Contributor
 
Join Date: Feb 2007
Posts: 64
Thanks: 9
Killswitch is on a distinguished road
Default Cleaning data before entering database question

Hello all, I know what to use to clean data before sending it to the database, but have a question about whether this would work out or not...

I am using XAJAX to send all form values in an array to a function which enters the database and returns a success message. Instead of checking if magic quotes is on or off, and cleaning each post individually based upon that, is it safe to run a foreach on the $aFormData array variable and clean just that? Would that clean each of the posted values?

I can clean each by $aFormData = stripslashes($aFormData['section_title']) and so on, but it just creates a huge block and don't think it is much needed.

Basically, this is what the function is looking like so far...

Code:
function addSectionData ( $aFormData ) {

	if(get_magic_quotes_gpc()) {
        	$secname        = stripslashes( $_POST['secname'] );
        	$description    = stripslashes( $_POST['description'] );
		$ordering       = stripslashes( int( $_POST['ordering'] ) );
		$access         = stripslashes( int($_POST['access'] ) );
		$publishing     = stripslashes( int($_POST['publishing'] ) );
        } else {
        	$secname        = $_POST['secname'];
        	$description    = $_POST['description'];
		$ordering       = $_POST['ordering'];
		$access         = $_POST['access'];
		$publishing     = $_POST['publishing'];
        }

	$password = md5( trim ( $aFormData['password'] ) );	
// Query down here, not going to continue, not needed
}
I also plan to slap a mysql_real_escape_string (I made a new function to use instead, just to shorten the name) in the actual query.

One final question... do I have to send the password through strip slashing as well?

Thanks for your support :D
Killswitch is offline  
Reply With Quote
 


LinkBacks (?)
LinkBack to this Thread: http://www.talkphp.com/general/1797-cleaning-data-before-entering-database-question.html
Posted By For Type Date
TalkPHP - Powered by vBulletin This thread Refback 12-24-2007 02:45 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:42 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design