Hallo Leute,
ich möchte eine Klassenfunktion über das "action"-Attribut eines Formulares aufrufen. Geht sowas? Mein Projekt besteht bisher aus einer index.php die so aussieht:
Code:
<?php
include('classes\controller.php');
include('classes\view.php');
include('classes\model.php');
$controller = new Controller();
$controller->display();
?>
dann einer controller.php:
Code:
<?php
class Controller {
public function display() {
$view = new View();
$view->loadTemplate();
}
public function login() {
echo "login";
}
}
?>
und einer view.php:
Code:
<?php
class View {
public $data = 'test';
public function loadTemplate(){
include('templates/default.php');
}
}
?>
und einer default.php:
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="templates/style.css">
<title>Test</title>
</head>
<body>
<header>
<h1>Überschrift</h1>
</header>
<nav>
<ul>
<li>Eintrag 1</li>
<li>Eintrag 2</li>
</ul>
<form action="" method="post">
<label>Benutzername</label>
<input type="text" name="bname">
<label>Passwort</label>
<input type="password" name="bpassw">
<button type="submit">login</button>
</form>
</nav>
<main>
<p>Das ist der Main-Bereich</p>
</main>
<footer>
<p>Das ist der Footer-Bereich</p>
</footer>
<!-- <?php //echo $this->data; ?> -->
</body>
</html>
... wie kann ich jetzt die Funktion $controller->login() aus der Form aufrufen?
Danke schonmal
P.S. Ich hoffe es gibt eine einfache schöne Lösung