Reply to Re: Foreach element in $_POST?

Your name:

Reply:


Posted by Peter Fox on 12/07/05 11:26

Following on from Carl's message. . .
>
>Easy, just treat $_POST as an array and use foreach.
>http://www.php.net/manual/en/control-structures.foreach.php
>
>Don't forget to make the post values safe before using them if they were
>input by the users...
>
Further don't forget that elements of $_POST may be arrays in their own
right. eg Checkboxes. Here is a snippet of code as illustration


#---------------------------------------------------------------------
function POSTget($VarName,$tidy=TRUE){
# read POSTed value from HTTP_POST_VARS
# Normally we'll tidy up the input to remove leading and trailing spaces
and control chars
# but this can be overridden.
#---------------------------------------------------------------------
if (isset($_POST[$VarName])){
$rv = $_POST[$VarName];
if(!is_array($rv)){
if ($tidy) {$rv = TidyInput($rv);}
}
}else{
$rv='';
}
return $rv;
}

--
PETER FOX Not the same since the porcelain business went down the pan
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

[Back to original 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

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