Session id is not showing with an error message Notice: Undefined index: UserID also if i redirect non logged in users i will not log into the home page iether.. here is my file could anyone please show me where i am going wrong.
here is the home page:
<?php
require ("insert.php");
session_start();
if (isset($_SESSION["UserID"])){
}
else {
echo "session not transferring";
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>AMSadler</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="Anthony">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/home.css">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<a href="index.html"><img src="img/logo.png" alt="logo" title="AMSadler.com"/></a>
</div>
<div id="headertop">
<div id="pagetitle">
<a href="home.php">HOME</a>
</div>
<div id="pagetitle2">
<a href="profile.php">PROFILE</a>
</div>
<div id="pagetitle3">
<h4>Welcome:<?php echo $_SESSION{"UserID"};?>to your page</h4>
</div>
</div>
</div>
<div class="wrapper">
<div class="leftsidebar">
<ul>
<li><a href="home.php">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
</ul>
</div>
<div class="main">
<div id="maintop">
<div id="textboxwrap">
<textarea name="text" id="styled"rows="5" cols="80" placeholder="Write something here.">
</textarea>
</div>
<div id="postbutton">
<input type="submit" name="post" value="Post" />
</div>
</div>
<div id="mainbottom1">
<div ="mainbottomwrap">
Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>
Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>
Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>Your posts will go here.<br>
Your posts will go here.<br>Your posts will go here.<br>
</div>
</div>
</div>
<div class="rightsidebar">
<div id="profilecontainer">
<img src="img/profile.png" alt="Upload a profile pic" title="profile pic" />
</div>
<div id="box">
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a><br>
<a href="#">blah</a>
</div>
</div>
</div>
</body>
</html>
================================================================== and here is the login page to get there. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?php require ("insert.php"); ?>
<?php
if(isset($_POST[ 'Login' ]))
{
$email= mysqli_real_escape_string($con, $_POST ['email']);
$pswrd= mysqli_real_escape_string($con, $_POST ['pswrd']);
$result = $con->query (" select * from users where email='$email' AND pswrd='$pswrd' ");
$row = $result->fetch_array(MYSQLI_BOTH);
session_start();
$_SESSION["User ID"] = $row['UserID'];
header ('Location: home.php');
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>AMSadler login</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="Anthony">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/login.css">
<link rel="index" href="index.php">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<a href="index.html"><img src="img/logo.png" alt="logo" title="AMSadler.com"/></a>
</div>
<div id="signup">
<button type="button"><a href="signup.php">Sign up</a></button>
</div>
</div>
<div id="login">
<form action="home.php" method="post">
<input type="text" name="email" placeholder="Email address">
<br>
<input type="password" name="password" placeholder="Password">
<br>
<input id="Login" type="submit" name="Login" value="Login">
</form>
</div>
<footer>
<div id="copyright">
<p>© Copyright 2015</p>
</div>
</footer>
</body>
</html>