Guest User

Untitled

a guest
Oct 16th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. try {
  3. $db = new PDO("sqlsrv:Server=WIN-H0CPAVNR2UISQLEXPRESS;Database=UsersForProject");
  4. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  5. } catch (PDOException $e) {
  6. print("Couldn't connect to the database".$e->getMessage());
  7. }
  8.  
  9. $user = json_decode($_REQUEST['user']);
  10.  
  11. $user->password = hash('md5', $user->password);
  12.  
  13.  
  14. $query = $db->exec("SELECT * FROM dbo.Users WHERE Login = '".$user->login."' AND Password = '".$user->password."'") or die("Query error");
  15. var_dump($query);
  16. if ($query==1) {
  17. $cookie_name = $user->login;
  18. $cookie_value = $user->password;
  19. setcookie($cookie_name, $cookie_value, time() + 3600);
  20. }?>
Add Comment
Please, Sign In to add comment