Guten Abend liebe User. Ich bin grad dabei eine Content Management System zu erstellen, und habe ein kleines Problem beim Login. Erstmal mein Code:
Mein Problem ist, wenn ich auf der Index bin und das ganze Forumular absende, bekomme ich nichts zürück. Wieso? Template System funktioniert einwandfrei.
Ich hoffe Ihr könnt mir helfen. :S
MfG.
#EDIT - Alles erledigt, habe die Methode Login() im Konstruktor ausgeführt!
PHP-Code:
<?php
class IndexPage extends Page {
public function __construct($template,$modelFactory) {
parent::__construct($template,$modelFactory);
}
public function Main() {
$this->getTemplate()->display('index/Index');
}
public function Login() {
if (isset($_POST['submit'])) {
$username = $this->getConnection()->real_escape_string($_POST['username']);
$password = sha1($this->getConnection()->real_escape_string($_POST['password']));
$CheckAcc = $this->getConnection()->query("SELECT * FROM ht_users WHERE username = '".$username."' AND password = '".$password."' LIMIT 1");
if($CheckAcc->num_rows > 0) {
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
header("Location: ");
} else {
echo "Falscher Benutzername oder Passwort!";
}
if(empty($_POST['username']) || empty($_POST['password'])) {
echo "Bitte fülle alle Felder aus!";
}
}
}
}
?>
PHP-Code:
<div id="divRight">
<form method="post">
<div class="form-group">
<input type="text" name="username" class="form-control" id="exampleInputPassword2" placeholder="Gebe hier dein Benutzernamen ein">
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" id="exampleInputPassword2" placeholder="Gebe hier dein Passwort ein...">
</div>
<input type="submit" value="Einloggen" name="submit" class="btn btn-primary" /> <a href="/register/" class="btn btn-success">Registrieren</a>
</form>
</div>
<?php
if(isset($error)) { ?>
<b><?php echo $error; ?></b>
<?php } ?>
MfG.
#EDIT - Alles erledigt, habe die Methode Login() im Konstruktor ausgeführt!
Kommentar