Advertisement
rofelbca

update

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