![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Kenneth Pardue say... > Here's what I have: > > In my form: > <input type='checkbox' name='checkbox[]' value='Option 1'> > <input type='checkbox' name='checkbox[]' value='Option 2'> > <input type='checkbox' name='checkbox[]' value='Option 3'> using checkbox above will not pass the variables to php like you intend, because as far as HTML is concerned, 'checkbox[]' isn't an array. So basically checkbox[] will only get passed as one of the above options, not all 3 (if all 3 are checked) You need to state the array keys in your html form. eg <input type='checkbox' name='checkbox[0]' value='Option 1'> <input type='checkbox' name='checkbox[1]' value='Option 2'> <input type='checkbox' name='checkbox[2]' value='Option 3'> I think this is the problem anyway HTH -- Nathan. XBL Gamertag: Cowfield http://www.cowfields.com Bow to the Cow! | |||
|
| Advertisements |
| | #2 | ||
| Nathan say... > I think this is the problem anyway D'oh! It isn't. Ignore the above post. it's late and I need my bed. leave the form as is, but your processing script should be like this: $strengths = $_REQUEST['strengths']; echo "<p>" . $strengths[0] . $strengths[1] . $strengths[2] . "</p>" Basically, lose the square brackets. Using square brackets is for dealing with one value of an array, losing the brackets means the array as a whole. I think anyway ![]() -- Nathan. XBL Gamertag: Cowfield http://www.cowfields.com Bow to the Cow! | |||
|
| | #3 | ||
| Kenneth Pardue wrote: > Hmmmm, this is odd. Trying it the second way seems to work if I have a > combination of any two or all three checked (with the caveat that when I > print them out I have the word "Array" thrown at the end of them). > Selecting just one or none results in an undefined offset error. > > Trying it with a combination of your first post > (name='strengths[1]'...etc) results in it working, but I get that > accursed undefined offset error for options that are unchecked. > > Kenneth > > > Nathan wrote: > >> Nathan say... >> >> >>> I think this is the problem anyway >> >> >> >> D'oh! It isn't. Ignore the above post. it's late and I need my bed. >> >> leave the form as is, but your processing script should be like this: >> >> $strengths = $_REQUEST['strengths']; >> >> echo "<p>" . $strengths[0] . $strengths[1] . $strengths[2] . "</p>" >> >> Basically, lose the square brackets. Using square brackets is for >> dealing with one value of an array, losing the brackets means the >> array as a whole. I think anyway ![]() >> You can do echo "<p> @$strengths[0] $@strengths[1] @$strengths[2] </p>"; hope tha helps -- From the mind of Andrew Kicks Remove nospam to reply | |||
|
| | #4 | ||
| Kicksy wrote: > Kenneth Pardue wrote: > >> Hmmmm, this is odd. Trying it the second way seems to work if I have >> a combination of any two or all three checked (with the caveat that >> when I print them out I have the word "Array" thrown at the end of >> them). Selecting just one or none results in an undefined offset error. >> >> Trying it with a combination of your first post >> (name='strengths[1]'...etc) results in it working, but I get that >> accursed undefined offset error for options that are unchecked. >> >> Kenneth >> >> >> Nathan wrote: >> >>> Nathan say... >>> >>> >>>> I think this is the problem anyway >>> >>> >>> >>> >>> D'oh! It isn't. Ignore the above post. it's late and I need my bed. >>> >>> leave the form as is, but your processing script should be like this: >>> >>> $strengths = $_REQUEST['strengths']; >>> >>> echo "<p>" . $strengths[0] . $strengths[1] . $strengths[2] . "</p>" >>> >>> Basically, lose the square brackets. Using square brackets is for >>> dealing with one value of an array, losing the brackets means the >>> array as a whole. I think anyway ![]() >>> > > You can do > > echo "<p> @$strengths[0] $@strengths[1] @$strengths[2] </p>"; > |||| Should be @$strengths[1] sorry. I blame the keyboard. > hope tha helps > > > -- From the mind of Andrew Kicks Remove nospam to reply | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: checkboxes, forms, help, learning, php |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Learning PHP - Need Help with Forms (Checkboxes) | Kenneth Pardue | PHP | 0 | 07-01-2007 4:00 PM |
| attachments in forms | Jukka K. Korpela | HTML | 0 | 07-01-2007 1:50 PM |
| Automate filling out web forms ?? | Terry King | HTML | 3 | 07-01-2007 1:23 PM |
| corel pdf forms | Ruth | Graphics in general | 7 | 05-28-2007 7:57 PM |
| Using SendMail in Forms w/PHP HTML | jcage@lycos.com | PHP | 3 | 05-20-2007 6:33 PM |
| Featured Websites | ||||
|