I am currently trying to setup an admin login for a webpage. Currently, I have 2 logins set up, admin1 and admin2. Currently when I login with admin1, even after logging out and relogging in with admin2, the admin1 data still shows up.
I have my MySQL database setup so all data about admin1 is in one row, and each user has their own row. Here is my code. I have a decent understanding of PHP, but am really just a late beginner. I generally understand the code and what it’s doing, but am still working on being able to write complicated functions.
Any help would be greatly appreciated. Thank you in advance.
[size=18pt]
CODE: LOGIN SUCCESS[/size]
<?php
session_start(); //Start the session
define(ADMIN,$_SESSION['myusername']); //Get the user name from the previously registered super global variable
if(!session_is_registered($myusername)){ //If session not registered
header("location:login.php"); // Redirect to login.php page
}
else //Continue to current page
header( 'Content-Type: text/html; charset=utf-8' );
?>
<?php
header( 'Location: http://www.theindigopath.com/test/admin.php' ) ;
?>
[size=18pt]
CODE: CONNECT CODE I HAVE ADDED INCLUDED IN THE TOP OF THE PAGE[/size]
<?php // Make a MySQL Connection
mysql_connect("MYHOST", "USERNAME", "PASSWORD") or die(mysql_error());
mysql_select_db("DB") or die(mysql_error());
// Retrieve all the data from the "users" table
$result = mysql_query("SELECT * FROM users WHERE username = '$myusername' AND password = '$password'")
or die(mysql_error());
// store the record of the "users" table into $row
$row = mysql_fetch_array( $result ); ?>
[size=18pt]
CODE: ADMIN MAIN PAGE[/size]
Administration
<?php
include(“connect.php”); ?>
<?php
//Calculate 60 days in the future
//seconds * minutes * hours * days + current time
$inTwoMonths = 60 * 60 * 24 * 1 + time();
setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths);
?>
<?php
// Retrieve all the data from the "users" table
$result = mysql_query("SELECT * FROM users WHERE username = '$myusername' AND password = '$password'")
or die(mysql_error());
// store the record of the "users" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo "You are logged in as ".$row['username']; ?>
| Logout? |
<?php
if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit'];
else
echo "Welcome Back!";
echo "Your last visit was - ". $visit;
?>
<?php
echo "
"; ?>
Image: ![]()
<?php
echo "Status: ".$row['status'];
echo "
";
echo "Blurb: " ?><?php
$quote_style = ENT_QUOTES;
echo html_entity_decode(html_entity_decode($row[‘blurb’], $quote_style), ENT_QUOTES);
?>
Change your status:
Available
Busy
Unavailable
Choose a file to upload:
<?php $quote_style = ENT_QUOTES;
echo html_entity_decode(html_entity_decode($row['blurb'], $quote_style), ENT_QUOTES); ?>