Reputation: 47
Why my echo
doesn't print the value 1
?
<dl>
<input type='checkbox' class='tinyField' name="informTktUpdate['hd']" value="1" /> Inform user by email
</dl>
<dl>
<input type='checkbox' class='tinyField' name="informTktUpdate['prog']" value="1" /> Inform programmer by email
</dl>
echo ($_POST['informTktUpdate']['prog']);
echo ($_POST['informTktUpdate'][prog]);
I tried to remove the quotes:
name="informTktUpdate[prog]"
But still nothing...
Upvotes: 0
Views: 45
Reputation: 139
try to change
<input type='checkbox' class='tinyField' name="informTktUpdate['prog']" value="1" />
to
<input type='checkbox' class='tinyField' name="informTktUpdate[prog]" checked="checked" value="1" />
let it be checked by default and then echo $_POST['informTktUpdate']['prog'];
Upvotes: 0
Reputation: 146450
Your HTML fields have these names:
informTktUpdate['hd']
informTktUpdate['prog']
Thus you need to add those quotes to the key names:
$_POST["informTktUpdate"]["'hd'"]
$_POST["informTktUpdate"]["'prog'"]
Since quotes in name
attribute only add unnecessary verbosity, I suggest you simply get rid of them to begin with. Remember HTML is not PHP.
Also, please note you can use any regular dump function to inspect your variables, there's no need to guess:
var_dump($_POST);
array(1) {
["informTktUpdate"]=>
array(2) {
["'hd'"]=>
string(1) "1"
["'prog'"]=>
string(1) "1"
}
}
Last but not least, this code:
echo ($_POST['informTktUpdate'][prog]);
... should be triggering a notice. The fact that you don't see it suggests that you haven't configured your PHP development box to display error messages. If you fix that, further coding should be more focused.
Upvotes: 1
Reputation: 12127
in HTML, No need to single quote (')
inside []
params in input name attribute
change
<input type='checkbox' class='tinyField' name="informTktUpdate['hd']" value="1" />
to
<input type='checkbox' class='tinyField' name="informTktUpdate[hd]" value="1" />
And try on server side
echo $_POST['informTktUpdate']['prog'];
Upvotes: 0
Reputation: 943569
It isn't entirely clear from your question it appears that it is because:
Upvotes: 1