I am making a website for my final for my scripting class. Until yesterday the login was working correctly. I cleared cookies in my browser (Chrome) but that still shouldn't cause it to break in other browsers (Firefox) or other machines. So I'm assuming something is wrong in the code. My code works like this, which I have used basically for other websites for class that have worked fine. First is index.php which is just this
<?php
require_once 'includes/init.php';
?>
and a call to a function to make it load everything on that page (index.php?content=whatever) init.php (which I copied from our book and have been using has this.
require_once 'includes/functions.php';
require_once 'includes/database.php';
session_start();
functions.php just has the load content function, and database.php is just to connect to the database. Login.php is just a simple form that goes to checklogin.php which has this
<?php
$username = $_POST["username"];
$password = $_POST["password"];
$check = mysql_query("SELECT * FROM users WHERE user = '" . $username . "'");
if($check === FALSE)
{
die(mysql_error());
}
$result = mysql_fetch_array($check);
if ($result['password'] == $password)
{
echo "Login successful";
$_SESSION['loggedIn'] = 1;
echo "<script>location.href='index.php?content=frontPage'</script>";
?>
<meta HTTP-EQUIV="REFRESH" content="0; url=index.php?content=frontPage">
<?php
}
else
{
echo "Login unsuccessful";
echo "<br>";
echo "<a href='index.php?content=login'>Try Again</a>";
}
?>
Does anyone know the problem or why it just stopped working? Or just a different way of doing this? The problem seems to be that when I put a "echo session_id();" on different pages, every time it loads another page the session id will change.
Subreddit
Post Details
- Posted
- 10 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...