I've created a login script using php and I use MySQL database to store user data. Everything was working fine until I got to know that one of my friend ( whose account is also created like me in the database ) called me and said that my profile was automatically loaded on his phone. How can this be even possible as my session data or anyone's session cannot be created without the filling of the login form with their respective credentials!?
Help me with this! As this is a major loop with the security of a user data as without their consent, how could it be accessible from someone else phone!!
Session creation through login.php
session_start();
if (isset($_POST['email']) and isset($_POST['password'])){
$email = $_POST['email'];
$password = $_POST['password'];
$query = "SELECT * FROM `users` WHERE email='$email' and password='$password'";
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result) > 0){
$_SESSION['email'] = $email;
$_SESSION['id'] = $id;
echo "You are logged in.";
header("Location: index.php?log=success");
unset($_POST);
}
else{
echo " Something went wrong ";
}
}