I have an index.php and a login function that gets opened when clicking on a submit button. Now whenever the button is being clicked, the user won't be logged in, as nothing is happening, and I can't figure out the issue.
Small snippet of index.php:
Username:<br> <img src="/images/figure.png" alt="Icon" height="42" width="42>">
<input type="text" name="username"><br>
Passwort:<br> <img src="/images/Key_lock.png" alt="Icon" height="42" width="42>">
<input type="password" name="passwort"><br>
<input type="submit" login="loginfunc()" value="Login">
</form>
and my loginfunc
<?php
session_start();
include 'globals.php';
if(empty($_POST["username"]) || empty($_POST["passwort"]))
{
echo "Bitte tragen Sie ihr Passwort und Benutzername ein";
}
else {
$query = "SELECT * FROM benutzer WHERE username = '$username'";
$result = mysqli_query($con, $query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
if(password_verify($passwort, $row["password"]))
{
session_start();
$_SESSION['username'] = $username;
header("Location:dashboard.php");
}
else
{
echo "Kevin";
}
}
}
else
{
}
}
?>