So I'm creating a login section. However, I'm not sure if it actually logs the user in. I have a table with UserID (A_I), email, password and all the usual stuff. So when I log in, I'm trying to fetch and echo the UserID on the account page, just to show that the user is logged in, but still haven't got any success with it.
Login form:
<form method="post" action="">
<div class="FormElement">
<input name="email" type="text" required="required" class="TField" placeholder="Email">
</div>
<div class="FormElement">
<input type="Password" required="required" class="TField" placeholder="Password">
</div>
<div class="FormElement">
<input name="LogIn" type="submit" class="button" value="LogIn">
</div>
</form>
Login php script:
<?php require 'Connections/Connections.php'; ?>
<?php
if (isset($_POST['LogIn'])){
$EM = $_POST['email'];
$PW = $_POST['password'];
$result = $con->query("select * from user where Email='$EM' AND Password='$PW'");
$row = $result->fetch_array(MYSQLI_BOTH);
session_start();
$_SESSION["UserID"] = $row['UserID'];
header('Location: Account.php');
}
?>
As you can see in the script, we're heading to Account.php, where I am basically trying to:
<?php echo $_SESSION["UserID"]; ?>
However, no UserID is being echo'ed. No errors, notices or warnings.
The Connections.php ($con) is just a normal connection to the MYSQLI table, and it connects just fine.
Pretty new around here and any help is appreciated!
Thanks in advance.