chop Posted January 28, 2012 Share Posted January 28, 2012 Looks like an easy question here but I just don't see it.. getting old: Why doesn't this work: if (isset($_POST['submitted'])) { // Handle the form // Trim all the incoming data: $trimmed = array_map('trim', $_POST); echo "The media is ".$_POST['media[0]']; [color=#ff0000]// THIS COMES UP WITH NO VALUE: "The media is "[/color] exit(); // CHECK BOX INPUTS WITHIN FORM <p>* check all that apply but at least one of the following:</p> <p> <label> <input type="checkbox" [color=#ff0000]name="media[]"[/color] value="acrylic" id="" />[color=#ff0000]// this is the first in the list[/color] acrylic</label> <br /> <label> <input type="checkbox" name="media[]" value="checkbox" id="" /> Checkbox</label> <br /> <label> <input type="checkbox" name="media[]" value="charcoal" id="" /> note that "print_r($_POST['media']);" works fine and prints the whole array Link to comment Share on other sites More sharing options...
Edward Posted January 28, 2012 Share Posted January 28, 2012 What is the result of the php error handler, which part exactly doesn't work? 1 Link to comment Share on other sites More sharing options...
rob Posted January 29, 2012 Share Posted January 29, 2012 media will be an array within the $_POST array; to access the values you need to use the method you would for a multimensional array $_POST['media'][0]. Alternatively, you could assign $_POST['media'] to a variable and then access the media values using $array[0]. 1 Link to comment Share on other sites More sharing options...
chop Posted February 1, 2012 Author Share Posted February 1, 2012 I understand, makes sense now. I knew my syntax was incorrect but wasn't getting an error. This worked for Me; $mediaArray=$_POST['media']; echo $mediaArray[0]; //works fine $_POST['media'][0]; // works as well thank you Link to comment Share on other sites More sharing options...
Recommended Posts