Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "coucou";
  5. $dbname = "outland";
  6.  
  7. try {
  8. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  9. // set the PDO error mode to exception
  10. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. }
  12. catch(PDOException $e)
  13. {
  14. echo $sql . "<br>" . $e->getMessage();
  15. }
  16.  
  17. $id = '';
  18.  
  19. if( isset( $_GET['id'])) {
  20. //deleting the row from table
  21. $sql = "DELETE FROM users WHERE id=:id";
  22. $query = $conn->prepare($sql);
  23. $query->execute(array(':id' => $_GET['id']));
  24. }
  25. //redirecting to the display page (index.php in our case)
  26. header("Location:index.php");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement