Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

checkbox array help


  • Please log in to reply

#1
mikhael

mikhael

    Member

  • Member
  • PipPip
  • 39 posts
I am making a rather large form for one of my sites and I have a section asking interests using checkboxes. I wanted all of the checkboxes to have the same name but a value corrisponding to the interest. I then attempted to call these variables in php with the post command but I am having issues.

<input name="checkbox[]" type="checkbox" value="value1" />

<input name="checkbox[]" type="checkbox" value="value2" />

<input name="checkbox[]" type="checkbox" value="value3" />  

<input name="checkbox[]" type="checkbox" value="value4" />

<input name="checkbox[]" type="checkbox" value="value5" />

<input name="checkbox[]" type="checkbox" value="value6" />

now in the php script I want to use each value but for example's sake lets just echo the selected values

<?php
$box = is_array($_POST['checkbox']);

echo $box;
?>

except all I get is the word "Array" to echo. What am I doing wrong?
  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,676 posts
is_array($_POST)

That only checks if it exists if I'm not mistaking.

Maybe this will help you:
http://phpprogrammin...n-form-element/
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP