Hi,
I'm having troubles with the following variable from an HTML form :
<input type="checkbox" value="1" name="changecheck">
there is only 1 checkbox in the HTML form, the value of "changeckeck" is either "1" if checked or nothing if not checked.
Here is the php code :
$changecheck=$HTTP_POST_VARS['changecheck'];
if ($changecheck !== "1")
This works fine if the checkbox is checked, but if it is not, there is an error message :
Notice: Undefined index: changecheck in c:\program files\easyphp1-7\www\microsent\pages\pass_answer.php on line 16
(Line 16 is : if ($changecheck !== "1")).
Who can help ?
problem with HTML checkbox variable in PHP, please help
Moderator: General Moderators
- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland
Code: Select all
if (isset($HTTP_POST_VARS["changecheck"])) { // If the checkbox has been check, then set the var
$changecheck = $HTTP_POST_VARS["changecheck"]));
}Simple
Mark
- orangeapple
- Forum Commoner
- Posts: 70
- Joined: Tue Jan 06, 2004 1:24 pm
- Location: Geneva / Switzerland
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Just curious, are you sure you need to use the 'not identical' operator (!==) in place of the 'not equal' (!=)? Is there any reason why not just:orangeapple wrote:Code: Select all
if ($changecheck !== "1")
Code: Select all
if ($changecheck != "1")Regards,
Scorphus.