这是我的登录功能中的一个简短代码。我在尝试从特定用户获取 id 并将其索引到新会话时遇到问题。代码已注释,希望你们能帮助我。
$email = mysql_real_escape_string($_POST['email']);
$password = md5(mysql_real_escape_string($_POST['password']));
include_once("include/connection.php");
$query = "SELECT email,password,id FROM user WHERE email ='".$email."' AND password='".$password."'";
$result = mysqli_query($ligaBD,$query);
$value= mysqli_fetch_array($result);
echo $value['id']; // On this line i get the exact id that i want but if i try to echo this inside "if(mysqli_num_rows($result) == 1) { }" its like the value variable does not exist
if(mysqli_num_rows($result) == 1) {
session_start();
echo $value['id']=$_SESSION['id'];exit; // Getting this error -> "Notice: Undefined index: id"
header("Location: ./cpanel/#welcome");
}