ridyko

Buat file update.php untuk memperbarui data pengguna.

Jul 29th, 2024
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2. include 'db.php';
  3.  
  4. $id = $_GET['id'];
  5.  
  6. $sql = "SELECT * FROM users WHERE id=$id";
  7. $result = $conn->query($sql);
  8. $user = $result->fetch_assoc();
  9. ?>
  10.  
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14.     <meta charset="UTF-8">
  15.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  16.     <title>Update User</title>
  17.     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  18. </head>
  19. <body>
  20. <div class="container mt-5">
  21.     <h2 class="mb-4">Update User</h2>
  22.  
  23.     <form action="update_process.php" method="post">
  24.         <input type="hidden" name="id" value="<?php echo $user['id']; ?>">
  25.         <div class="mb-3">
  26.             <label for="name" class="form-label">Name</label>
  27.             <input type="text" class="form-control" id="name" name="name" value="<?php echo $user['name']; ?>" required>
  28.         </div>
  29.         <div class="mb-3">
  30.             <label for="email" class="form-label">Email</label>
  31.             <input type="email" class="form-control" id="email" name="email" value="<?php echo $user['email']; ?>" required>
  32.         </div>
  33.         <button type="submit" class="btn btn-primary">Update User</button>
  34.     </form>
  35. </div>
  36. </body>
  37. </html>
  38.  
Add Comment
Please, Sign In to add comment