Guest User

Untitled

a guest
Jan 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $passwd = "";
  5. $dbname="municipio";
  6. try {
  7. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $passwd);
  8. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);}
  9. catch(PDOException $e)
  10. {
  11. echo "Connection failed: " . $e->getMessage();}
  12.  
  13. if($_POST['tipoUser']== 'municipe'){
  14. $stmt = $conn->prepare("SELECT * FROM municipes WHERE user = :user AND password = :pass");
  15. $stmt->bindParam(':user', $_POST['user'], PDO::PARAM_STR);
  16. $stmt->bindParam(':pass', $_POST['password'], PDO::PARAM_STR);
  17. echo '<script type="text/javascript">alert("Nice Inteligente muni");</script>';}
  18. else{
  19. $stmt = $conn->prepare("SELECT * FROM funcionarios WHERE user = :user AND password = :pass");
  20. $stmt->bindParam(':user', $_POST['user'], PDO::PARAM_STR);
  21. $stmt->bindParam(':pass', $_POST['password'], PDO::PARAM_STR);
  22. echo '<script type="text/javascript">alert("Nice Inteligente func");</script>';}
  23.  
  24. $stmt->execute();
  25.  
  26. $obj=$stmt->fetchObject();
  27.  
  28. if ($obj){
  29. echo '<script type="text/javascript">alert("Nice Inteligente");</script>';}
  30.  
  31. $conn=null;
  32. ?>
Add Comment
Please, Sign In to add comment