forms - php what does checkbox default value 'on' -


recently while working checkbox, i've go through following test code:

<?php if ( isset( $_post['myname'] ) ) { $myvalue = $_post['myname']; echo $myvalue; } ?>  <form method="post"> <input type="checkbox" name="myname" /> <input type="submit" name="send" /></form> 

so, output got after form submission when checkbox checked prints 'on' else nothing (if value not provided on checkbox). , isn't supposed print 1(true) on checking checkbox. 'on' means in php?

if don't provide value attribute checkbox, it's value on

with

<input type="checkbox" name="myname" /> 

$_post['myname'] value on

with

<input type="checkbox" name="myname" value="1" /> 

$_post['myname'] value 1

in both cases when checkbox unchecked, doesn't present in $_post (not set)


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -