I am programming a login system. When i click on submit, it stays in the userController and doesn't echo anything. i'm fairly new when it comes to programming so can anyone help me with this issue?
This is what it looks line in the template:
<div class="container">
<div class="top">
<h1 id="title" class="hidden"><span id="logo"> <img src="assets/img/logo.jpg" alt="Commercium logo"></span>
</div>
<div class="login-box animated fadeInUp">
<div class="box-header">
<h2>Log In</h2>
</div>
<form method="post" action="../controller/userController.php">
<input name="action" type="hidden" value="loginUser" required/>
<label for="email">E-mail adres</label>
<br/>
<input type="email" name="email" placeholder="enter email">
<br/>
<label for="wachtworrd">Wachtwoord</label>
<br/>
<input type="password" name="password" placeholder="Password">
<br/>
<button type="submit" value="Login" name="login">Sign In</button>
<br/>
<a href="index.php"><p class="small">
</p></a>
</div>
</div>
This is what it looks like in the controller
if (isset($_POST['login'])) {
$login = $user->loginUser($_POST['email'], $_POST['password']);
}
and this is the class
public function loginUser($email, $password)
{
$stmt = $this->connect()->prepare("SELECT * FROM users WHERE email= ? AND password= ? ");
$stmt->bind_param('ss', $email, $password);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->num_rows;
if ($num_rows == 1) {
echo 'U bent ingelogd!';
}
if ($num_rows == 0)
{
echo "geen gegevens";
}
}