i cant seem to get it working, would someone be able to help me create the code i will need to show the currents logged in users name on a page after logging in. i have a seperate login.php page as the "home" page. once logged in it will redirect to menu.php which is where i want to be able to show the name of the logged on user.
Connect.php is the seperate script connecting to the database. "gebruikersnaam" is dutch for username "wachtwoord" is dutch for password. "recht" is a dutch word for rights ( just the right if they are allowed to log in yes/no "ja/nee" )
hopefully someone can help :D
<?php
session_start();
include_once 'connect.php';
if(isset($_SESSION['user'])!="") {
header("Location: login.php");
}
if(isset($_POST['btn-login'])) {
$Gebruikersnaam = $_POST['Gebruikersnaam'];
$wachtwoord = $_POST['wachtwoord'];
$res=mysqli_query($conn, "SELECT * FROM accounts WHERE Gebruikersnaam='$Gebruikersnaam'");
$row= $res->fetch_array(MYSQL_ASSOC);
$_SESSION['gebruikersnaam'] = $Gebruikersnaam;
if($row['wachtwoord']==($wachtwoord) AND ($row['recht']==("ja"))) {
$_SESSION['user'] = $row['ID'];
header("Location: menu.php");
} else {
echo "<script>alert('Verkeerde login details');</script>";
}
}
?>