I have just finished creating an entire login and register systsem in PHP, but my problem is I haven't used any sessions yet. I'm kind of a newbie in PHP and I've never used sessions before. Want to log in with session and some if errors in code cannot go to the dashboard page help me to solve this problem.
<?php
session_start();
error_reporting(0);
include('config.php');
if(isset($_POST['submit']))
{
$result = mysqli_query($dbh,"SELECT * FROM users WHERE email='" . $_POST["email"] . "' and password = '". $_POST["password"]."'");
$row = mysqli_fetch_array($result);
if(is_array($row)) {
$_SESSION["id"] = $row[id];
$_SESSION["username"] = $row[username];
} else {
$message = "Invalid Email or Password!";
}
}
if(isset($_SESSION["id"])) {
header("Location:dashboard.php");
}
?>
Want to log in with session and some if errors in code cannot go to the dashboard page help me to solve this problem.