Hi arenaTR!
I like using these functions:
function read_post( $param_name ) {
if( get_magic_quotes_gpc() ) {
return isset( $_POST[$param_name] ) ? stripslashes_array(
$_POST[$param_name] ) : null;
} else {
return isset( $_POST[$param_name] ) ? $_POST[$param_name] : null;
}
}
function stripslashes_array( $given ) {
return is_array( $given ) ? array_map( 'stripslashes_array', $given
) : stripslashes( $given );
}
The first one distinguishes between the absence of the parameter and a
parameter which is equal to ''. It also takes care of magic quotes, if
needed. The second function allows the built-in stripslashes to work on
arrays, if for instance, you pass something like checkboxes or a
multiple select.
If you want, you can name all of your five checkboxes like this:
<input type="checkbox" name="driving[]">
Then, just call read_post() like this:
$driving_values = read_post( 'driving' ); # an array of values
That way, you can later change the number of checkboxes without having
to change your PHP code.
Mike van Lammeren
arenaTR wrote:
I have a group of five checkboxes that I need to check in a script after a
post-operaiton. I was using the code:
$drv1 = $_POST['driving_1']
but if the user left checkbox "driving_1" empty, i get a php error upon
processing. So, I looked in the manual and found the fuction empty(). So I
tried:
If (empty($drv1)) {
then do this
}
But it doesn't seem to be working. Actually, what I really want is if not
equal to empty, something like:
If (!empty($drv1)) {
then do this
}
Your help is, as always, greatly appreciated.