You are here: Re: $_POST and Building SQL Strings « PHP Programming Language « IT news, forums, messages
Re: $_POST and Building SQL Strings

Posted by David Gillen on 05/04/07 13:15

Geoff Berrow said:
> Message-ID: <slrnf3m5ig.p4n.Belial@murphy.redbrick.dcu.ie> from David
> Gillen contained the following:
>
>>You can insert the following snippet
>>foreach($_POST as $key=>$val)
>>{
>> $$key = $val;
>>}
>
> Never trust user supplied data.
> But (for mysql) you could do:
> foreach($_POST as $key=>$val)
> {
> $$key = mysql_real_escape_string($val);
> }

The question posed didn't ask about any sort of input validation, hence I
didn't address it. Obviously after the foreach above you should check all the
variables passed are valid. Again though it is easier to work with
validate($var); than validate($_POST['var']); in terms of readability though.

D.

PS: I knew as soon as I'd posted someone would point out the code wasn't
checking the user passed data.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация