Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. // Importing DBConfig.php file.
  4. include 'DBConfig.php';
  5.  
  6. // Creating connection.
  7.  $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
  8.  
  9.  // Getting the received JSON into $json variable.
  10.  $json = file_get_contents('php://input');
  11.  
  12.  // decoding the received JSON and store into $obj variable.
  13.  $obj = json_decode($json,true);
  14.  
  15. // Populate User email from JSON $obj array and store into $email.
  16. $email = $obj['email'];
  17.  
  18. // Populate Password from JSON $obj array and store into $password.
  19. $password = $obj['password'];
  20.  sleep(2);
  21. //Applying User Login query with email and password match.
  22. $Sql_Query = "select * from user where username = '$email' and password = '$password' and userStatus='Y' ";
  23.  
  24. // Executing SQL Query.
  25. $check = mysqli_fetch_array(mysqli_query($con,$Sql_Query));
  26.  
  27.  
  28. if(isset($check)){
  29. $sqlToken = "select token from user where username ='$email'";
  30. $result = $con->query($sqlToken);
  31. $row1 = $result->fetch_assoc();
  32. $token= $row1["token"];
  33.  
  34.  $SuccessLoginMsg = $token;
  35.  
  36.  // Converting the message into JSON format.
  37. $SuccessLoginJson = json_encode($SuccessLoginMsg);
  38.  // sleep for 10 seconds
  39.  
  40. // Echo the message.
  41.  echo $SuccessLoginJson ;
  42.  
  43.  }
  44.  
  45.  else{
  46.  
  47.  // If the record inserted successfully then show the message.
  48. $InvalidMSG = '0' ;
  49.  
  50. // Converting the message into JSON format.
  51. $InvalidMSGJSon = json_encode($InvalidMSG);
  52.  
  53. // Echo the message.
  54.  echo $InvalidMSGJSon ;
  55.  
  56.  }
  57.  
  58.  mysqli_close($con);
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement