i made a little web application in university and have some problems with data access.
There are 3 user accounts which can log in and all of them can create their own lectures afterwards.
Problem: Each teacher should only see the lectures he created and not the ones the other two created. At the moment every teacher sees every lecture.
I don't know which code I should post here, but I am very thankful for any kind of help!
Thanks so much!
Edit: Thanks for your answer. I tried it the last few hours, but I have not idea what to to anymore.
That's my code where I save the lecture into the database. There seems to be a problem with the $_SESSION.
public function save(Vorlesung $vorlesung)
{
try {
$stmt = $this->pdo->prepare('
INSERT INTO vorlesung
(name, login_dozent)
VALUES
(:name, '$_SESSION[dozent]')
');
$stmt->bindParam(':name', $vorlesung->name);
$stmt->execute();
} catch (PDOException $e) {
echo("Fehler! Bitten wenden Sie sich an den Administrator...<br>" . $e->getMessage() . "<br>");
die();
}
return $vorlesung;
}
That's my login code:
<?php
require_once("Mapper/DozentManager.php");
require_once("Mapper/Dozent.php");
$login = htmlspecialchars($_POST["login"], ENT_QUOTES, "UTF-8");
$password = htmlspecialchars($_POST["password"], ENT_QUOTES, "UTF-8");
if (!empty($login) && !empty($password)) {
$DozentManager = new DozentManager();
$dozent = $DozentManager->findByLogin($login, $password);
if ($dozent==null) {
header('Location: login.php');
die();
} else {
session_start();
$_SESSION ['dozent'] = $dozent;
$_SESSION ['login'] = "1";
header('Location: index.php');
die();
}
} else {
echo "Error: Bitte alle Felder ausfüllen!<br/>";
}