Advertisement
jagata

Untitled

Aug 19th, 2021
1,406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4.  
  5. if(isset($_POST["statusii"]))
  6.  {
  7.  
  8.     $aidi = mysqli_real_escape_string($conn,$_POST["statusii"]);
  9.  
  10.     $sel = mysqli_query($conn,"SELECT statu FROM chanaweri WHERE id = $aidi");
  11.         $fet = mysqli_fetch_assoc($sel);
  12.         // var_dump($fet["statu"];)
  13.         if($fet["statu"] == "0"){
  14.             $ondate = date("Y-m-d");
  15.             $upd = mysqli_query($conn,"UPDATE chanaweri SET statu = '1', ondate = '$ondate' WHERE id = $aidi");
  16.             // header("Location: index.php");
  17.             // echo "string";
  18.       echo true;
  19.         }else{
  20.       echo false;
  21.         }
  22.         if($fet["statu"] == "1"){
  23.             $upd = mysqli_query($conn,"UPDATE chanaweri SET statu = '0', ondate = '' WHERE id = $aidi");
  24.             // header("Location: index.php");
  25.         echo true;
  26.         }else{
  27.       echo false;
  28.         }
  29.         // echo "string";
  30.  
  31.     exit;
  32.     }
  33.  
  34. ?>
  35. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  36.  
  37. <tr>
  38. <?php
  39.   $arr = array("id"=>412,"statu"=>'1');
  40. ?>
  41.  
  42.         <td><form method="post" action="" id="contactform">
  43.           <input type="submit" id="statusii" name="statusii" value="<?php echo $arr['id']?>" hidden><input type="checkbox" <?php if($arr["statu"] == '1'){echo "checked";}?> data-toggle="toggle">
  44.           <input type="submit" id="submit" value="submit">
  45.         </form></td>
  46.  
  47.  
  48.       </tr>
  49.  
  50.     </tbody>
  51.   </table><br><br><br>
  52. </div>
  53.  
  54. <script>
  55.   $(document).ready(function () {
  56.     $('#submit').click(function (e) {
  57.  
  58.       e.preventDefault();
  59.       var aidi = $('#statusii').val();
  60.         $.ajax({
  61.           type: "POST",
  62.           url: "", //"status.php",
  63.           data: { "statusii": aidi },
  64.           success: function (data) {
  65.             alert(data);
  66.             $('.result').html(data);
  67.             $('#contactform')[0].reset();
  68.           }
  69.         });
  70.     });
  71.   });
  72. </script>
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement