You are here: Re: How do get the state of checkboxes in php? « PHP Programming Language « IT news, forums, messages
Re: How do get the state of checkboxes in php?

Posted by larry on 09/09/07 02:40

Keep in mind if no boxes are checked you don't get the value passed
back. Following are a couple functions I put together to retain my
sanity in checklists and other array input use it like:

$arrayname = postarrayfix('postarrayname');

It strips out any potentially bad HTML and slashes if magic quotes are
on.


/*$_POST Fixer, if the following lists are empty, the POSTs return
nulls, which is bad, as the code needs arrays (even empty) to display,
this fixes it.*/

function postArrayFix($postname){
if( empty($_POST[$postname]) ){
$value = array();
} else {
$value = cleanArray($_POST[$postname]);
}
return $value;
}

/*This one is for if you are reading in arrays from $_POST data, it
will walk deep into the array and clean it up.
*/

function cleanArray($value)
{
if(get_magic_quotes_gpc()) {
$value = is_array($value) ?
array_map('cleanArray', $value) :
stripslashes(strip_tags($value));
} else {
$value = is_array($value) ?
array_map('cleanArray', $value) :
strip_tags($value);
}
return $value;
}

 

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

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