html - Get checkbox value with php -


i try determine if checkbox checked or not, error.

test.php

<html>     <body>         <form method="post" action="<?php echo $_server['php_self'];?>">              use proxy : <input type="checkbox" name="use_proxy"><br><br>              <input type="submit">         </form>          <?php              $use_proxy  = $_post['use_proxy'];              if ($use_proxy != "on")             {                 $use_proxy = "off";             }              echo "<p> use_proxy = " . $use_proxy . "</p><br>";          ?>     </body> </html> 

i error: notice: undefined index: use_proxy in c:\xampp\htdocs\mbcl\checkbox_test.php on line 11 how can solve it?

this behaviour of checkbox until checked , can not fetched @ backend(php) . can try below-

<html>     <body>         <form method="post" action="<?php echo $_server['php_self'];?>">              use proxy : <input type="checkbox" name="use_proxy" value="off"><br><br>              <input type="submit">         </form>          <?php              $use_proxy  = isset($_post['use_proxy'])?"on":"off";             echo "<p> use_proxy = " . $use_proxy . "</p><br>";          ?>     </body> </html> 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -