JOHN JOHNNNY

JOHN JOHNNNY

  • NA
  • 190
  • 135.1k

Android Php Mysql Prevent Multiple User Login

Dec 18 2019 10:12 AM
Hi software gurus
I developed an android app that will require users to have access to a premium features by using a code/password to unlock the activity, i have a working login.php file and all the code/password is already stored in the database server which will be given to each user to login to access premium features. My question goes thus is there a way to make a user logged in, another user should not be able to log in with the same information codes/passwords i.e to be used once inorder to prevent multiple users of a aprticular codes/passwords. See the attached login.php file for editing, i look forward to a favourable response thanks in advance
 
See my login.php below
 <?php
include "config.php";
 
$response = array();
if($_POST['email'] && $_POST['password']){
$email = $_POST['email'];
$post_password = $_POST['password'];
$stmt = $conn->prepare("SELECT username, password FROM users WHERE email = ?");
$stmt->bind_param("s",$email);
$stmt->execute();
$stmt->bind_result($username, $db_password);
$stmt->fetch();
if(password_verify($post_password, $db_password)){
$response['error'] = false;
$response['message'] = "Login Successful!";
$response['email'] = $email;
$response['username'] = $username;
} else{
$response['error'] = false;
$response['message'] = "Invalid Email or Password";
}
} else {
$response['error'] = true;
$response['message'] = "Insufficient Parameters";
}
echo json_encode($response);
?>

Answers (1)