Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.63 KB | None | 0 0
  1.  
  2.  
  3.     <?php
  4.  
  5.  
  6. /*
  7.     if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
  8.         header('Access-Control-Allow-Origin: *');
  9.         header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
  10.         header('Access-Control-Allow-Headers: token, Content-Type');
  11.         header('Access-Control-Max-Age: 1728000');
  12.         header('Content-Length: 0');
  13.         header('Content-Type: text/plain');
  14.         die();
  15.     }
  16.  
  17.     header('Access-Control-Allow-Origin: *');
  18.     header('Content-Type: application/json');
  19.  
  20.     $data = json_decode(file_get_contents("php://input"));
  21.     include("connect.php");
  22.     if(!isset($_POST)) die();
  23.  
  24.     session_start();
  25.     $response = [];
  26.  
  27.     $username = mysqli_real_escape_string($connect, $_POST['usernamex']);
  28.     $password = mysqli_real_escape_string($connect, $_POST['password']);
  29.  
  30.     $query = "SELECT * FROM green_admin WHERE wap_username='$username' AND wap_password='$password'";
  31.     $result = mysqli_query($connect, $query);
  32.     if(mysqli_num_rows($result) > 0){
  33.         $response['status'] = 'loggedin';
  34.         while($row = mysqli_fetch_array($result))  
  35.         {
  36.             $response['user'] = $row;
  37.         }
  38.     }else{
  39.         $response['status'] = 'error';
  40.     }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.         echo json_encode($response);
  47.  
  48.  
  49.  
  50. */
  51.  
  52.  
  53.  
  54.  
  55.   if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
  56.     header('Access-Control-Allow-Origin: *');
  57.     header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
  58.     header('Access-Control-Allow-Headers: token, Content-Type');
  59.     header('Access-Control-Max-Age: 1728000');
  60.     header('Content-Length: 0');
  61.     header('Content-Type: text/plain');
  62.     die();
  63.   }
  64.  
  65.   header('Access-Control-Allow-Origin: *');
  66.   header('Content-Type: application/json');
  67.  
  68.     $data = json_decode(file_get_contents("php://input"));
  69.  
  70.     if(!isset($_POST)) die();
  71.  
  72.     session_start();
  73.     $response = [];
  74.  
  75.    // include ('connect.php');
  76.     $connect = mysqli_connect("173.214.172.82", "kahoncom_da2z", "", "kahoncom_dollar");
  77.  
  78.     $username = mysqli_real_escape_string($connect, $_POST['usernamex']);
  79.     $password = mysqli_real_escape_string($connect, $_POST['password']);
  80.  
  81.     $query = "SELECT * FROM users WHERE email='$username' AND password='$password'";
  82.    
  83.     $result = mysqli_query($connect, $query);
  84.       if(mysqli_num_rows($result) > 0){
  85.         $response['status'] = 'loggedin';
  86.         while($row = mysqli_fetch_array($result))  
  87.         {
  88.             $response['user'] = $row;
  89.         }
  90.       }else{
  91.         $response['status'] = 'error';
  92.       }
  93.  
  94.    
  95.         echo json_encode($response);
  96.    
  97.  
  98.  
  99.    
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement