I hate to be confusing, but I'm not sure at this point if the problem lies within the PHP Login not working, or if the redirecting isn't working. I'll post what I have so far in both the Login.php and the target page I'm trying to redirect to.
Login.php:
<?php if(isset($_POST["Login"])){
if(!empty($_POST['user']) && !empty($_POST['pass'])) {
$user=$_POST['user'];
$pass=$_POST['pass'];
$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('users') or die("cannot select DB");
$query=mysql_query("SELECT * FROM userdata WHERE user='".$user."' AND pass='".$pass."'");
$numrows=mysql_num_rows($query);
if($numrows!=0)
{
while($row=mysql_fetch_assoc($query))
{
$dbusername=$row['user'];
$dbpassword=$row['pass'];
}
if($user == $dbusername && $pass == $dbpassword)
{
session_start();
$_SESSION['sess_user']=$user;
/* Redirect browser */
header("Location: ./Programs/Content/Home.php");
}
} else {
echo "Invalid username or password!";
} } else {
echo "All fields are required!"; }}?> }
Then there's just some CSS and basic HTML stuff, but here's the form itself:
<div class="login">
<form action="" method=POST>
<center>
<p><input id="user" name="user" type="text" placeholder="Username"></p>
<p><input id="pass" name="pass" type="password" placeholder="Password"></p>
<input type="submit" value="Login">
</center>
</form> </div>
And here's the header code for Home.php:
<?php
session_start();
if(!isset($_SESSION["sess_user"])){
header("location:../../Login.php");
} else {
?>
then there's the page contents, and at the end there's:
<?php } ?>