Advertisement
Nerkes

index.php

Jan 18th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. require 'db.php';
  4. if (isset($_POST))
  5. {
  6.  
  7. $login = $_POST['login'];
  8. $password = $_POST['pass'];
  9. $vhod = $db->query("SELECT `id` FROM `users` WHERE `login` = '$login' AND `password` = '$password'");
  10. $id_user = mysqli_fetch_assoc($vhod);
  11. if (empty($id_user['id']))
  12. {
  13.  
  14.  
  15. echo 'Ошибка';
  16. }
  17. else
  18. {
  19. $arr = array(
  20. "username" => $login,
  21. "password" => $password
  22. );
  23.  
  24. $request = json_encode($arr, true);
  25. file_put_contents('config.json', $request);
  26. $_SESSION['login'] = $login;
  27. header("Location: catalog.php");
  28. echo json_encode($arr);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement