Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
  3. header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
  4. header('Access-Control-Max-Age: 1000');
  5. header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
  6.  
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "asterisk";
  10. $dbname = "ionic";
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14.  
  15. // Check connection
  16. if ($conn->connect_error) {
  17. die("Connection failed: " . $conn->connect_error);
  18. }
  19. $data = json_decode(file_get_contents('php://input'),true);
  20. $login = $data['login'];
  21. $password = $data['password'];
  22.  
  23. $sql = "SELECT * FROM login WHERE login = '$login' AND password = '$password'";
  24. $result = $conn->query($sql);
  25.  
  26. if ($result->num_rows > 0) {
  27.  
  28. echo json_encode(array('status'=>'Sucesso','code'=>200));
  29. } else {
  30. echo json_encode(array('status'=>'Login falhou', 'code'=>500));
  31. }
  32. $conn->close();
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement