SHARE
TWEET

Untitled

a guest Oct 13th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'koneksi.php';
  3.  
  4. if(isset($_POST['save'])){
  5. $Id = $_GET['id'];
  6. $Nama = $_POST['Nama'];
  7. $Username = $_POST['Username'];
  8. $Password = $_POST['Password'];
  9. $Email = $_POST['Email'];
  10.  
  11. $query = "UPDATE data SET nama='$Nama', Username='$Username', Password='$Password', Email='$Email' WHERE Id=$Id";
  12.  
  13. if(mysqli_query($koneksi, $query)){
  14.     header("location:index.php");
  15. }else{
  16.  
  17.  
  18. }
  19.  
  20. }
  21. ?>
  22.  
  23. <!DOCTYPE html>
  24. <html>
  25. <head>
  26.     <title>Membuat CRUD Dengan PHP Dan MySQL</title>
  27.     <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  28. </head>
  29. <body>
  30.     <div class="judul bg-dark text-light p-3 mt-3 mb-3">       
  31.         <h1>Membuat CRUD Dengan PHP Dan MySQL</h1>
  32.     </div>
  33.    
  34.     <br/>
  35.    
  36.     <a href="index.php" class="btn btn-info">Lihat Semua Data</a>
  37.  
  38.     <br/>
  39.     <h3>Edit data</h3>
  40.  
  41.     <?php
  42.     include "koneksi.php";
  43.     $id = $_GET['id'];
  44.     $query_mysql = mysqli_query($koneksi, "SELECT * FROM data WHERE id='$id'");
  45.     $nomor = 1;
  46.     while($data = mysqli_fetch_array($query_mysql)){
  47.     ?>
  48.     <form action="" method="post">     
  49.         <table>
  50.             <tr>
  51.                 <td>Id</td>
  52.                 <td>
  53.                     <input type="hidden" name="id" value="<?php echo $data['Id'] ?>" required>
  54.                 </td>                  
  55.             </tr>  
  56.             <tr>
  57.                 <td>Nama</td>
  58.                 <td><input type="text" name="Nama" value="<?php echo $data['Nama'] ?>" required></td>                  
  59.             </tr>  
  60.             <tr>
  61.                 <td>Username</td>
  62.                 <td><input type="text" name="Username" value="<?php echo $data['Username'] ?>" required></td>                  
  63.             </tr>
  64.             <tr>
  65.                 <td>Password</td>
  66.                 <td><input type="text" name="Password" value="<?php echo $data['Password'] ?>" required></td>                  
  67.             </tr>
  68.             <tr>
  69.                 <td>Email</td>
  70.                 <td><input type="text" name="Email" value="<?php echo $data['Email'] ?>" required></td>
  71.             </tr>          
  72.             <tr>
  73.                 <td></td>
  74.                 <td><input type="submit" value="Simpan" name="save" class="btn btn-warning"></td>                  
  75.             </tr>              
  76.         </table>
  77.     </form>
  78.     <?php } ?>
  79.     <script type="text/javascript" src="bootstrap.min.js"></script>
  80. </body>
  81. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top