Advertisement
Guest User

eror

a guest
Nov 4th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <h2 class="text-center">Edit Data Diri</h2>
  2. <hr>
  3.  
  4. <?php
  5.     $koneksi = new mysqli("localhost","root","","first");
  6.  
  7.  ?>
  8.  
  9.  
  10.  
  11. <form method="get">
  12.     <?php $ambil=$koneksi->query("SELECT * FROM pelanggan"); ?>
  13.     <?php $pecah=$ambil->fetch_assoc()  ?>
  14.     <div class="form-group">
  15.         <label>Nama</label>
  16.         <input type="text" name="nama" class="form-control" value="<?php echo $pecah['nama']; ?>">
  17.     </div>
  18.     <div class="form-group">
  19.         <label>Username</label>
  20.         <input type="text" name="username" class="form-control" value="<?php echo $pecah['username']; ?>">
  21.     </div>
  22.     <div class="form-group">
  23.         <label>Password</label>
  24.         <input type="text" name="password" class="form-control" value="<?php echo $pecah['password']; ?>">
  25.     </div>
  26.     <button class="btn btn-success" name="ubah">Ubah</button>
  27.    
  28. </form>
  29.  
  30. <?php
  31.     if (isset($_POST['ubah'])) {
  32.    
  33.             $koneksi->query("UPDATE pelanggan SET nama='$_POST[nama]', username='$_POST[username]', password='$_POST[password]' WHERE nama='$_GET[nama]'");
  34.  
  35.         echo "<script>alert('Data berhasil di ubah');</script>";
  36.         echo "<script>location='profil.php?halaman=editprofil';</script>";
  37.         }
  38.    
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement