Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. $connection = mysqli_connect("localhost","root","","loginapp");
  3. if(!$connection){
  4. echo "Connection Failed.";
  5. }
  6. $query = "SELECT * FROM users";
  7. $result = mysqli_query($connection,$query);
  8. if(!$result){
  9. die("Query dismissed".mysqli_error($connection));
  10. }
  11.  
  12. if(isset($_POST['submit'])){
  13. $username = $_POST['name'];
  14. $password = $_POST['password'];
  15. $id = $_POST['id'];
  16. $query = "UPDATE users SET username = '$username' password = '$password' WHERE 'id' = '".$id."'";
  17.  
  18. $result = mysqli_query($connection, $query);
  19. if(!$result){
  20. die("Query FAILED" . mysqli_error($connection));
  21. }
  22. }
  23. ?>
  24. <!DOCTYPE html>
  25. <html lang="en">
  26. <head>
  27. <meta charset="UTF-8">
  28. <title>Document</title>
  29. </head>
  30. <body>
  31. <form action = "Update.php" method = "post">
  32. <input type = "name" name = "name" placeholder = "Type your name">
  33. <input type = "password" name = "password" placeholder = "Type your password"><br>
  34. <select name="id" id="">
  35. <?php
  36. while($row = mysqli_fetch_assoc($result)){
  37. $id = $row["id"];
  38. echo "<option value='$id'>$id</option>";
  39. }
  40. ?>
  41. </select>
  42. <input type = "submit" name = "submit" value = "Update">
  43. </form>
  44. </body>
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement