Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_POST 1

Status
Not open for further replies.

chessbot

Programmer
Mar 14, 2004
1,524
US
I've been searching the php.net documentation, but I haven't found anything useful.

If I have a check box without a value, such as this
Code:
<input type="checkbox" name="Bob_party">

and I reference $_POST['Bob_party'], what will it return if the value is checked? Unchecked? Not in the form? Are the last two different?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Here's the simple answer with an example:
Code:
<?php
print_r($_POST);
?>
<html><body>
<form method="post">
<input type="checkbox" name="testing">
<input type="submit" value="submit" name="go">
</form></body>
</html>
Please forgive the incomplete HTML.
However, when the box is cheked it is set to "on". The output shows
Code:
Array ( [testing] => on [go] => submit )
If it is not checked, it will be absent and the output is:
Code:
Array ( [go] => submit )
Hope that answers the question.
 
It does. Unfortunately.

I am looking for some way to have three possible states with one checkbox: not defined, checked, and unchecked. Is this possible without using hidden fields?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Ah well. Thanks anyway.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top