Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Importing DBConfig.php file.
- include 'DBConfig.php';
- // Creating connection.
- $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
- // Getting the received JSON into $json variable.
- $json = file_get_contents('php://input');
- // decoding the received JSON and store into $obj variable.
- $obj = json_decode($json,true);
- // Populate User email from JSON $obj array and store into $email.
- $email = $obj['email'];
- // Populate Password from JSON $obj array and store into $password.
- $password = $obj['password'];
- sleep(2);
- //Applying User Login query with email and password match.
- $Sql_Query = "select * from user where username = '$email' and password = '$password' and userStatus='Y' ";
- // Executing SQL Query.
- $check = mysqli_fetch_array(mysqli_query($con,$Sql_Query));
- if(isset($check)){
- $sqlToken = "select token from user where username ='$email'";
- $result = $con->query($sqlToken);
- $row1 = $result->fetch_assoc();
- $token= $row1["token"];
- $SuccessLoginMsg = $token;
- // Converting the message into JSON format.
- $SuccessLoginJson = json_encode($SuccessLoginMsg);
- // sleep for 10 seconds
- // Echo the message.
- echo $SuccessLoginJson ;
- }
- else{
- // If the record inserted successfully then show the message.
- $InvalidMSG = '0' ;
- // Converting the message into JSON format.
- $InvalidMSGJSon = json_encode($InvalidMSG);
- // Echo the message.
- echo $InvalidMSGJSon ;
- }
- mysqli_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement