I am working on my website and, for the life of me, can't seem to get the username to pop up on my index.html page after it redirects a user to the page after they log in.
connectivity.php
function SignIn()
{
session_start(); //starting the session for user profile page
if(!empty($_POST['user'])) //checking the 'user' name which is from Sign-In.html, is it empty or have some text
{
$query = mysql_query("SELECT * FROM UserName where userName = '$_POST[user]' AND pass = '$_POST[pass]'") or die(mysql_error());
$row = mysql_fetch_array($query) or die(mysql_error());
if(!empty($row['userName']) AND !empty($row['pass']))
{
$_SESSION['userName'] = $row['pass'];
header("location: http://www.gotospectrum.com/index.html");
} else {
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
}
if(isset($_POST['submit']))
{
SignIn();
}
?>
index.html
<?php
session_start();session_destroy();
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="about.html">About</a>
</li>
<li>
<a href="Services.html">Services</a>
</li>
<li>
<a href="index.php">Contact</a>
</li>
<li>
<a href="Login/Sign-In.html">Login</a>
</li>
<li>
<a href="/Login/logout.php">Logout</a>
</li>
<li>
<?php
echo isset($_SESSION['userName'];
?>
</li>
I'm calling the session at the top as you can see and I'm trying to echo the username in the <li>
after Logout, I'll move it later, but at this point I'm just trying to get it to work.
I have been at this now for hours and it's really frustrating me.