Advertisement
rofelbca

delete

Jul 25th, 2024 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.93 KB | None | 0 0
  1. <?php
  2.     $con= new mysqli('localhost','root','','crudop');
  3.     if(isset($_GET['deleteid'])){
  4.       $id=$_GET['deleteid'];
  5.      
  6.  
  7.       //insert query
  8.       $sql = "delete from company where id=$id";
  9.      
  10.  
  11.       //execute query
  12.       $result=mysqli_query($con,$sql);
  13.  
  14.       // we will check
  15.       if($result) {
  16.         echo "deleted successfully";
  17.         header('Location:display.php');
  18.           }else{
  19.             die(mysqli_error($con));
  20.           }
  21.         }<?php
  22.     $con= new mysqli('localhost','root','','crudop');
  23.     if(isset($_POST['submit'])){
  24.         $visitors=$_POST['visitors'];
  25.         $contact=$_POST['contact'];
  26.         $purpose=$_POST['purpose'];
  27.        
  28.        
  29.  
  30.       //insert query
  31.       $sql = "INSERT INTO company( visitors, contact, purpose)
  32.      VALUES( '$visitors', '$contact','$purpose' )";
  33.  
  34.       //execute query
  35.       $result=mysqli_query($con,$sql);
  36.  
  37.       // we will check
  38.       if($result) {
  39.         echo "data inserted successfully";
  40.         header('Location:display.php');
  41.           }else{
  42.             die(mysqli_error($con));
  43.           }
  44.         }
  45. ?>
  46. <!doctype html>
  47. <html lang="en">
  48.   <head>
  49.     <!-- Required meta tags -->
  50.     <meta charset="utf-8">
  51.     <meta name="viewport" content="width=device-width, initial-scale=1">
  52.  
  53.     <!-- Bootstrap CSS -->
  54.     <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  55.  
  56.     <title>php crud</title>
  57.   </head>
  58.   <body>
  59.     <div class="container">
  60.         <form method="post">
  61.   <div class="mb-3">
  62.     <label> VISITORS_NAME </label>
  63.     <input type="text" class="form-control" name="visitors" >
  64.   </div>
  65.   <div class="mb-3">
  66.     <label> CONTACT</label>
  67.     <input type="email" class="form-control" name="contact">
  68.   </div>
  69.   <div class="mb-3">
  70.     <label> PURPOSE</label>
  71.     <input type="text" class="form-control" name="purpose ">
  72.   </div>
  73.  
  74.  
  75.   <button type="submit" class="btn btn-primary" name="submit">Submit</button>
  76. </form>
  77. </div>
  78.  
  79.     <!-- Optional JavaScript; choose one of the two! -->
  80.  
  81.     <!-- Option 1: Bootstrap Bundle with Popper -->
  82.     <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  83.  
  84.     <!-- Option 2: Separate Popper and Bootstrap JS -->
  85.     <!--
  86.     <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
  87.     <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
  88.     -->
  89.   </body>
  90.   </html>
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement