Advertisement
Guest User

Untitled

a guest
Aug 21st, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. session_start();
  3. echo 'Bem vindo, '.$_SESSION['username'];
  4. ?>
  5. <br /><a href='logout.php'>Logout</a>
  6.  
  7. <?php
  8. if(isset($_POST["button"])){
  9. $hostname='localhost';
  10. $username='root';
  11. $password='';
  12.  
  13. try {
  14. $dbh = new PDO("mysql:host=$hostname;dbname=projeto",$username,$password);
  15.  
  16. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
  17. $del = "DELETE FROM tbl_users WHERE id =".$_SESSION['id'];
  18.  
  19.  
  20. if ($dbh->query($sql)) {
  21. echo "<script type= 'text/javascript'>alert('Conta deletada com sucesso'); </script>";
  22. }
  23. else{
  24. echo "<script type= 'text/javascript'>alert('Falha');</script>";
  25. }
  26.  
  27. $dbh = null;
  28. }
  29. catch(PDOException $e)
  30. {
  31. echo $e->getMessage();
  32. }
  33.  
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement