I am using a script to login (this itself works perfectly) to start a session and transmit the ID of the user who is logged in. In the same way, I want to transmit the "rolle" from my SQL-Table. Although the ID works just fine, "rolle" is claimed to be undefined. In my SQL table the column "rolle" is defined and filled.
Notice: Undefined property: stdClass::$rolle in /Applications/XAMPP/xamppfiles/htdocs/flensburgpunkte/login.php on line 35
if (isset($_GET["login"])) {
$email = $_POST["email"];
$passwort = $_POST["passwort"];
$passwort_hash = password_hash($passwort, PASSWORD_BCRYPT, ['salt' => 'ahsdIOUOASDHuahsjavnsdvuhJNDJASJdhafmvndvjvav732643849']);
$search_user = $connection->prepare("SELECT id FROM login WHERE email = ? AND passwort = ?");
$search_user->bind_param('ss',$email,$passwort_hash);
$search_user->execute();
$search_result = $search_user->get_result();
if ($search_result->num_rows == 1) {
$search_object = $search_result->fetch_object();
echo $search_object->id."<br>";
echo $search_object->rolle."<br>";
$_SESSION['fahrer'] = $search_object->id;
} else {
echo "<p style=\"color:#B80C09;\">Deine Angaben waren nicht korrekt.</p><br>";
}
}
$search_object->id
works just fine, but $search_object->rolle
does not work, although it comes from the same row, the id is read from.
Could somebody give me a solution which also provides a result for $search_object->rolle
?