Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2. require('connection.php');
  3. $username = $_POST['user'];
  4. $password = $_POST['pass'];
  5. $id = '';
  6.  
  7. try{
  8. $parancs = $dbh->prepare("select * from users where username = :username and password = :password and id = :id");
  9. $parancs->bindParam(':username', $username, PDO::PARAM_STR,strlen($username));
  10. $parancs->bindParam(':password', $password, PDO::PARAM_STR,strlen($password));
  11. $parancs->bindParam(':id', $id, PDO::PARAM_STR,strlen($id));
  12. $parancs->execute();
  13. }
  14. catch (PDOException $e){
  15. echo 'Hiba' . $e->getMessage();
  16. }
  17.  
  18. $row = $parancs->fetch(PDO::FETCH_ASSOC);
  19.  
  20. if ($row['username'] == $username && $row['password'] == $password ){
  21. echo "Login success!! Welcome ".$row['username'];
  22. header("Location: home.php");
  23. } else {
  24. echo "Failed to login!";
  25. }
  26. $parancs=null;
  27. $dbh=null;
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement