Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
01-29-2013, 03:41 AM #1
What Values get submitted with this Form?
When the following Form gets submitted...
<input name='friendRequestDecision' type='hidden' value='0' />
<input id='Requestor1_1' name='friendRequestDecision' type='radio' value='0' checked='checked' />
<label for='Requestor1_1'>Decide Later</label>
<input id='Requestor1_2' name='friendRequestDecision' type='radio' value='1' />
<input id='Requestor1_3' name='friendRequestDecision' type='radio' value='2' />
1.) What values get returned to my script?
2.) Is the first "hidden" field part of $_POST ?
3.) And is there a conflict between name='friendRequestDecision' in my Hidden Input and in my Regular Inputs?
I put var_dump in my code and got this...
array 'friendRequestDecision' => array 38 => string '1' (length=1) 1 => string '1' (length=1) 'submit' => string 'Update Requests' (length=15)
All of these questions are centered around SECURITY and making sure I check for the right values in the right places so that a hacker can't sneak in something bad?!
P.S. When I test the above code, it appears to be working okay as far of what is echoed on the screen and what gets updated in my database, but I figured I better check with the gurus here!!
01-29-2013, 04:36 AM #2
- Join Date
- Jan 2013
- Thanked 0 Times in 0 Posts
When you set your input's name to anything containing  in it, php picks it up as a mufti dimensional array, causing your output issue, use another delimiter such as varname_23 or you could do this...
here was my resultPHP Code:
function MultiArrayToSingle ($array)
$my_post_vars = array();
foreach ($array as $key => $value)
foreach($value as $k => $v)
$my_post_vars[$key."_".$k] = $v;
$my_post_vars[$key] = $value;
From the $_POST variable
[friendRequestDecision] => Array
 => 1
[button] => Submit
After $_POST was ran though my function
[friendRequestDecision_38] => 1
[button] => Submit
Last edited by jalex718; 01-29-2013 at 04:40 AM.
01-29-2013, 02:51 PM #3
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
You cannot share the same name with non-toggleable inputs. Radio and checkbox are fine as they require the same name in order to determine successful field groups. The hidden will be overwritten by the radio group following it. See your var dump results, you have selected accept for friendRequestDecision and friendRequestDecision.
So to answer your question, yes both get submitted. But only the latter one is successful. I'm not sure why you want that hidden field though; even if no option is selected, it would be presumable that you cannot pass a non-existent id into a query to update. If you cannot do that, than it is implicitly ignored.
So in other words, the hidden input is useless.
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');