javascript - How do I get a value from a check box with PHP? -


i have form there check box, on selecting box values different page gets loaded through ajax, after loading these values user can select them , submit , save in database.

values getting loaded properly, when submit form, values not getting carried backend.

<!doctype html> <head>     <script>     $(document).ready(function () {         $('#drive').change(function () {             if ($(this).is(':checked')) {                 var catid = $('#drive').val();                 console.log($('#drive'))                 if (catid != 0)                  {                     lodinganimate();                     $.ajax({                         type: 'post',                         url: 'c_datetime.php',                         data: {                             id: catid                         },                         cache: false,                         success: function (returndata) {                             $('#datetime').html(returndata);                             console.log(returndata)                         }                     });                      function lodinganimate() {                         $("#datetime").html('<img src="img/ajax-loader.gif" height="40" width="40"/>');                     }                 }             }else{                 $("#datetime").hide();             }         })     })     </script> </head> <body>       <?php         if($_post['save'])             {                 $datee = mysqli_real_escape_string($con, $_post['datee']);                 $timee = mysqli_real_escape_string($con, $_post['timee']);                 echo $datee;                 echo $timee;             }     ?>     <form class="form-horizontal"  enctype="multipart/form-data" role="form" action="<?php echo htmlspecialchars($_server["php_self"]);?>" method="post">         <input type="checkbox" name ="chk" id="drive" value="drive" style="margin-left: -20px;" >drive         <div id="datetime"> </div>         <button class="btn btn-default btn-border" style="color:white; border-radius: 25px;" type="submit" value="submit" name="save">proceed posting</button>     </form> </body> </html> 

c_datetime.php

<input type='text' class="form-control" name="datee" /> <input type='text' name="timee" class="form-control" /> 

can please tell how resolve issue?

you have error in part. see errors error_reporting(e_all);

<?php     if(isset($_post['save']))// added isset.         {             $datee = mysqli_real_escape_string($con, $_post['datee']);             $timee = mysqli_real_escape_string($con, $_post['timee']);             echo $datee;             echo $timee;         } ?> 

what $con?? if connection object, have missed include() in code.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -