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
acheoacheo
Forum Newbie
Posts: 2 Joined: Wed Jan 30, 2008 4:29 pm
Post
by acheoacheo » Wed Jan 30, 2008 4:34 pm
If that checkbox remains unchecked I can't retreive the value "off" in the $_POST variable when the form is submitted.
However if it is checked then I can retreive it...what's the problem??????????
Code: Select all
<input type="checkbox" name="Agreement" id="Debug" />
Code: Select all
if ($_POST['Agreement'] == "off"){
$error_message["agreement"] = "You haven't read the Terms of use.";
$isOk = 0;
}
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Wed Jan 30, 2008 4:54 pm
acheoacheo wrote: If that checkbox remains unchecked I can't retreive the value "off" in the $_POST variable when the form is submitted.
Absolutely correct!
acheoacheo wrote: However if it is checked then I can retreive it...what's the problem??????????
Code: Select all
if (! isset($_POST['Agreement'])){
$error_message["agreement"] = "You haven't read the Terms of use.";
$isOk = 0;
}
(#10850)
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed Jan 30, 2008 6:37 pm
empty() will be of great value to you here.
Festy
Forum Commoner
Posts: 28 Joined: Wed Jan 30, 2008 10:01 pm
Post
by Festy » Wed Jan 30, 2008 10:04 pm
If the checkbox is checked, you get the value 'on' but if it's unchecked you don't get any value at all (not even off) or even the refrence of your checkbox object for that matter.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu Jan 31, 2008 11:22 am
That is why you check empty() on it. If it is empty then it is not checked, otherwise, it is.