Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connection = mysqli_connect("localhost","root","","loginapp");
- if(!$connection){
- echo "Connection Failed.";
- }
- $query = "SELECT * FROM users";
- $result = mysqli_query($connection,$query);
- if(!$result){
- die("Query dismissed".mysqli_error($connection));
- }
- if(isset($_POST['submit'])){
- $username = $_POST['name'];
- $password = $_POST['password'];
- $id = $_POST['id'];
- $query = "UPDATE users SET username = '$username' password = '$password' WHERE 'id' = '".$id."'";
- $result = mysqli_query($connection, $query);
- if(!$result){
- die("Query FAILED" . mysqli_error($connection));
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <form action = "Update.php" method = "post">
- <input type = "name" name = "name" placeholder = "Type your name">
- <input type = "password" name = "password" placeholder = "Type your password"><br>
- <select name="id" id="">
- <?php
- while($row = mysqli_fetch_assoc($result)){
- $id = $row["id"];
- echo "<option value='$id'>$id</option>";
- }
- ?>
- </select>
- <input type = "submit" name = "submit" value = "Update">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement