Advertisement
Guest User

Untitled

a guest
Apr 7th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function login($login, $pass)
  2. {
  3. $cnx = new PDO("sqlsrv:Server=SRVLYCJ;Database=dbLogin_resseguier", "Resseguier","Resseguier13");
  4. $select = "
  5. SELECT user_id, username, userpassword
  6. FROM usertable
  7. WHERE username = '%s' AND userpassword = '%s';
  8. ";
  9.  
  10. $fixedlogin = $login;
  11. $fixedpass = $pass;
  12. $query = sprintf($select, $fixedlogin, $fixedpass);
  13. $req = $cnx->prepare($query);
  14.  
  15. $req->execute();
  16. // Récupération des résultats
  17. while ($row = $req->fetch(PDO::FETCH_OBJ))
  18. {
  19. $output[0] = $row->user_id;
  20.  
  21. }
  22.  
  23. if(empty($output[0]))
  24. {
  25. return -1;
  26. }
  27. else
  28. {
  29. return $output[0];
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement