php - If form is submitted, then checkbox checked -


i want make if form submitted then checkbox should checked.

here have:

<input type="checkbox" id="chk" <?php if ($_post['submit']){ echo checked } ?> /> 

html:

<form id="form1" enctype="multipart/form-data" action="" method="post">     //stuff here     <input name="submit" type="submit" value="upload" /> </form> 

i getting blank page when test it... appreciated.

blank because there php error of php code , have turned error_reporting off.

  1. if($_post['submit']) should if (isset($_post['submit']))

  2. echo checked should echo 'checked';

the sample below works me.

<form id="form1" enctype="multipart/form-data" action="" method="post">     //stuff here     <input name="submit" type="submit" value="upload" /> </form> <input type="checkbox" id="chk" <?php if (isset($_post['submit'])){ echo 'checked'; } ?> /> 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -