checkbox is missing from $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

checkbox is missing from $_GET

Post by davidklonski »

hi

I wrote this simple test program in file test.php:

Code: Select all

<?php

$arr = array_keys($_GET);
foreach ($arr as $key) {
	print $key . "<br>";	
}
?>

<html>
 <body>
  <form name="entry" method="GET" action="test.php">
   <input type="text" name="TX">
   <input type="checkbox" name="CH">
   <input type="submit">
   <input type="hidden" name="HD">
  </form>
 </body>
</html>
for some reason the checkbox is not being displayed as part of the $_GET array.

This is probably some stupid mistake on my part.
can anyone see it?

thanks in advance
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I can't reproduce it here, your script seems to work ok *shrug*
RadixDev
Forum Commoner
Posts: 66
Joined: Sun Mar 14, 2004 11:27 am
Location: U.K.

Post by RadixDev »

What happens if you put a value to the checkbox?
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

nothing new, the output is:
TX
HD
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

<input type="checkbox" name="CH[]">

Put an array value in there.
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

I did but still no checkbox...
It is as if the checkbox is not a part of the form
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you need to give the checkbox a value!

Code: Select all

<input type="checkbox" name="CH" value="checked">
The checkbox will ONLY appear if you have checked the check box

Mark
RadixDev
Forum Commoner
Posts: 66
Joined: Sun Mar 14, 2004 11:27 am
Location: U.K.

Post by RadixDev »

Bech100:-
RadixDev wrote:What happens if you put a value to the checkbox?
and he says:-
davidklonski wrote:I did but still no checkbox...
It is as if the checkbox is not a part of the form
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

yeah, i saw that, but i am guessing, when you told him to put a value in, he just checked the box and didn't change the code. Thats why i actually gave code to confirm this.

When typing a reply, in your head you know what YOU mean, but someone reading it can interpret in an entirely different way.

Mark
Post Reply