Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 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. if( isset( $_GET['id'])) {
  19. $id = $_GET['id'];
  20. }
  21. //getting id of the data from url
  22.  
  23. //deleting the row from table
  24. $sql = "DELETE FROM users WHERE id=:id";
  25. $query = conn->prepare($sql);
  26. $query->execute(array(':id' => $id));
  27.  
  28. //redirecting to the display page (index.php in our case)
  29. header("Location:index.php");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement