Jump to content

Login isn't working.


rofl90

Recommended Posts

My login isn't working it just refreshes and shows the form again. heres my codes:

 

check_login()

function check_login() {
    $id = session_id ();
    $start = $db->query ( "SELECT * FROM session WHERE session_id='$id'" );
    $start_n = $db->num_rows ( $start );
    if ($start_n == "0") {
        return "0";
    } else {
        $get_session_a = $db->fetch_array ( $start );
        $user_id = $get_session_a ["userid"];
        $check_user = $db->query ( "SELECT * FROM users WHERE id='$user_id'" );
        $c_u_n = $db->num_rows ( $check_user );
        if ($c_u_n == "0") {
            return "0";
        } else {
            $timeout = "900";
            $now = time ();
            $last = $get_session_a ["date"];
            $check = $now - $last;
            if ($check > $timeout) {
                return "0";
            } else {
                if ($get_session_a ["ip"] != $_SERVER ['REMOTE_ADDR']) {
                    return "0";
                } else {
                    $db->query ( "UPDATE session SET date='$now' WHERE session_id='$id'" );
                    return "1";
                }
            }
        }
    }
}

Login:

 

<?php
session_start();
include "config.php";
$action = $_GET["action"];
if (isset($action)) {
    $username = $_POST["username"];
    $password = md5($_POST["password"]);
   
    $get_username = $db->query("SELECT * FROM users WHERE user='$username' AND password='$password'");
    $get_username_n = $db->num_rows($get_username);
    if ($get_username_n == '0') {
        echo "Incorrect Username or Password, please try again.";
        exit ();
    } else {
        $get_username_a = $db->fetch_array ($get_username);
        $uid = $get_username_a['id'];
        $date = time();
        $session_id = session_id();
        $ip = $_SERVER ["REMOTE_ADDR"];
        $db->query ("DELETE FROM session WHERE session_id='$session_id'");
        $db->query ("DELETE FROM session WHERE userid='$uid'");
        $db->query ("INSERT INTO session (session_id, ip, date, userid) VALUES('$session_id', '$ip', '$date', '$uid')");
        echo "<meta http-equiv='refresh' content='0;index2.php' />";
        exit ();
    }
} else {
?>
<form action="?action=login" method="post">
<label>Your IP is <?php echo $_SERVER['REMOTE_ADDR']; ?>, and has been logged, unauthorised attempts to access will be logged, and steps will be taken. <br /></label>
<br />
<legend>Name</legend>
<input type="text" name="username" id="user" value="" />
(not case sensitive eg cHaRLiE becomes 'Charlie') <br />
<br />
<legend> Password</legend>
<input type="password" name="password" id="password" />
(cAsE sEnSiTiVe) <br />
<br />
<input type="submit" id="submit" name="login" value="Login" />
</form>

 

Finally database class>

 

<?php
/**
* Database core.
*/

class database {
   
    private $server;
    private $username;
    private $password;
    private $database;
   
    /**
     * Construct
     */
    function __construct() {
       
    }
   

   
    /**
     * Destruct
     */
    function __destruct() {
        unset ( $this->server );
        unset ( $this->username );
        unset ( $this->password );
        unset ( $this->database );
        mysql_close();
    }



   /**
     * Check, and begin connection.
     */
   
    public function connect($server, $username, $password, $database) {
        if ($server == NULL || $username == NULL || $database == NULL) {
            echo "Cannot connect.";
            exit();
        } else {
            $this->server = $server;
            $this->username = $username;
            $this->password = $password;
            $this->database = $database;
            $this->database_connect ();
        }
    }

   /**
     * Begin connection.
     */
   
    private function database_connect() {
        $conn = @mysql_connect ( $this->server, $this->username, $this->password );
        if ($conn == false) {
            $this->error (mysql_error());
        } else {
            $this->select_db ();
        }
    }


   /**
     * Select database.
     */
   
    private function select_db() {
        $select_db = mysql_select_db ( $this->database );
        if ($select_db == false) {
            $this->error (mysql_error());
        }
    }

   /**
     * Database query
     */
   
    public function query($query_text) {
        $query = mysql_query ( $query_text ) or die(mysql_error());
        return $query;
    }

   /**
     * Database fetch array
     */
   
    public function fetch_array($query_object) {
        $fetch = mysql_fetch_array ( $query_object );
        return $fetch;
    }

   /**
     * Database number rows
     */
   
    public function num_rows($query_object) {
        $num = mysql_num_rows ( $query_object );
        return $num;
    }

   /**
     * Database error.
     */
   
    public function error($text) {
        echo "There has been an error: <br /><br /> " .$text;
        exit ();
    }
}
?>

 

I havn't got a clue how this happens, because it exits on each evaluation in the login, and it simply just refreshes..

Link to comment
Share on other sites

index.php is the page that just refreshes. it holds the login, here ill give you the whole login fully:

 

 

<?php 
session_start (); 
include "config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="description" name="description" content="<?php $result = $db->query("SELECT * FROM settings") or die(mysql_error()); 
$row = $db->fetch_array($result); 
echo stripslashes($row['description']);
?>" />
<meta http-equiv="keywords" name="keywords" content="<?php echo stripslashes($row['keywords']);?>" />
<title><?php echo stripslashes($row['sitetitle']);?> » Login</title>
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/css/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/js.php" type="text/javascript" />
</head>
<body>
<div class="container">
  <div class="innercontainer">
    <div class="toppart">
    <div class="innertoppart">
      <div class="logo"> 
	  <img src="../go/images/headerimg.gif" alt="Codeetech" width="200" height="69" /> 
	  </div>
	  <div class="myslogan">
	    <div class="innermyslogan"> 
		Shinin' Backends Since '08.
		</div>
	  </div>
    </div>
    </div>
    <div class="backlinker">
Backend Home » Login </div>
<div class="stuff">
  <div class="leftmargin">
<div class="indentmebitch">
<?php
$action = $_GET["action"];
if (isset($action)) {
    $username = $_POST["username"];
    $password = md5($_POST["password"]);
   
    $get_username = $db->query("SELECT * FROM users WHERE user='$username' AND password='$password'");
    $get_username_n = $db->num_rows($get_username);
    if ($get_username_n == '0') {
        echo "Incorrect Username or Password, please try again.";
        exit ();
    } else {
        $get_username_a = $db->fetch_array($get_username);
        $uid = $get_username_a['id'];
        $date = time();
        $session_id = session_id();
        $ip = $_SERVER ["REMOTE_ADDR"];
        $db->query ("DELETE FROM session WHERE session_id='$session_id'");
        $db->query ("DELETE FROM session WHERE userid='$uid'");
        $db->query ("INSERT INTO session (session_id, ip, date, userid) VALUES('$session_id', '$ip', '$date', '$uid')");
        echo "<meta http-equiv='refresh' content='0;index2.php' />";
        exit ();
    }
} else {
?>
<form action="?action=login" method="post">
<label>Your IP is <?php echo $_SERVER['REMOTE_ADDR']; ?>, and has been logged, unauthorised attempts to access will be logged, and steps will be taken. <br /></label>
<br />
<legend>Name</legend>
<input type="text" name="username" id="user" value="" />
(not case sensitive eg cHaRLiE becomes 'Charlie') <br />
<br />
<legend> Password</legend>
<input type="password" name="password" id="password" />
(cAsE sEnSiTiVe) <br />
<br />
<input type="submit" id="submit" name="login" value="Login" />
</form>
</div>
</div>
<div class="right">
  <div class="navigation">
Backend:
</div>
	<div class="nav-link"><a href="http;//www.codeetech.com/">Site</a></div>
	<div class="nav-link">Backend</div>
  </div>
</div>
 </div>
 <div class="footer">
<?php echo stripslashes($row['footer']);?>
</div>
</div>
</body>
</html>
<?php } ?>

Link to comment
Share on other sites

<?php 
session_start (); 
include "config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="description" name="description" content="<?php $result = $db->query("SELECT * FROM settings") or die(mysql_error()); 
$row = $db->fetch_array($result); 
echo stripslashes($row['description']);
?>" />
<meta http-equiv="keywords" name="keywords" content="<?php echo stripslashes($row['keywords']);?>" />
<title><?php echo stripslashes($row['sitetitle']);?> » Login</title>
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/css/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/js.php" type="text/javascript" />
</head>
<body>
<div class="container">
  <div class="innercontainer">
    <div class="toppart">
    <div class="innertoppart">
      <div class="logo"> 
	  <img src="../go/images/headerimg.gif" alt="Codeetech" width="200" height="69" /> 
	  </div>
	  <div class="myslogan">
	    <div class="innermyslogan"> 
		Shinin' Backends Since '08.
		</div>
	  </div>
    </div>
    </div>
    <div class="backlinker">
Backend Home » Login </div>
<div class="stuff">
  <div class="leftmargin">
<div class="indentmebitch">
<?php
$action = $_GET["action"];
if (isset($action)) {
    $username = $_POST["username"];
    $password = md5($_POST["password"]);
   
    $get_username = $db->query("SELECT * FROM users WHERE user='$username' AND password='$password'");
    $get_username_n = $db->num_rows($get_username);
    if ($get_username_n == '0') {
        echo "Incorrect Username or Password, please try again.";
        exit ();
    } else {
        $get_username_a = $db->fetch_array($get_username);
        $uid = $get_username_a['id'];
        $date = time();
        $session_id = session_id();
        $ip = $_SERVER ["REMOTE_ADDR"];
        $db->query ("DELETE FROM session WHERE session_id='$session_id'");
        $db->query ("DELETE FROM session WHERE userid='$uid'");
        $db->query ("INSERT INTO session (session_id, ip, date, userid) VALUES('$session_id', '$ip', '$date', '$uid')");
        header('location: index2.php');
        exit ();
    }
} else {
?>
<form action="?action=login" method="post">
<label>Your IP is <?php echo $_SERVER['REMOTE_ADDR']; ?>, and has been logged, unauthorised attempts to access will be logged, and steps will be taken. <br /></label>
<br />
<legend>Name</legend>
<input type="text" name="username" id="user" value="" />
(not case sensitive eg cHaRLiE becomes 'Charlie') <br />
<br />
<legend> Password</legend>
<input type="password" name="password" id="password" />
(cAsE sEnSiTiVe) <br />
<br />
<input type="submit" id="submit" name="login" value="Login" />
</form>
</div>
</div>
<div class="right">
  <div class="navigation">
Backend:
</div>
	<div class="nav-link"><a href="http;//www.codeetech.com/">Site</a></div>
	<div class="nav-link">Backend</div>
  </div>
</div>
 </div>
 <div class="footer">
<?php echo stripslashes($row['footer']);?>
</div>
</div>
</body>
</html>
<?php } ?>

 

if that still dont work tell us what is your objectives with that codes i mean the expected output etc..

Link to comment
Share on other sites

Same.. just refreshed, in my first post, i expect it to work with the check_login()..

 

Maybe thats wrong, because it definitely updates the session id, and the session id equals it on pages I use

 

<?php

session_start ();

include "config.php";

 

if(check_login() == "0") {

    echo "You are not logged in.";

    exit();

}

 

When going to other pages it just redirects to index.php :S

Link to comment
Share on other sites

What is wrong with the code now, heres index2.php I tried echoing check_login() and it was a blank page ;S heres my code:

 

<?php
session_start ();
include "config.php";

if(check_login() == "0") {
    echo "You are not logged in.";
    exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="description" name="description" content="<?php $result = $db->query("SELECT * FROM settings"); $row = $db->fetch_array($result);echo stripslashes($row['description']);?>" />
<meta http-equiv="keywords" name="keywords" content="<?php echo stripslashes($row['keywords']);?>" />
<title><?php echo stripslashes($row['sitetitle']);?> » Succesful Logon!</title>
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/css/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/js.php" type="text/javascript"/>
</head>
<body>

<div class="container">

<!-- container START -->
  <div class="innercontainer">
<!-- innercontainer START -->
    <div class="toppart">
    <!-- toppart START -->
    <div class="innertoppart">
       <!-- innertoppart START -->
      <div class="logo"> 
	  <!-- logo START -->
	  <img src="../go/images/headerimg.gif" alt="Codeetech" width="200" height="69" /> 
	  
	  </div>
        <!-- logo END -->
	  <div class="myslogan">
          <!-- myslogan START -->
	    <div class="innermyslogan"> 
		<!-- innermyslogan START -->
		Welcome, <?php $session = session_id(); $get_user_id = $db->query("SELECT * FROM session WHERE session_id='$session'");
$fetch_user_id = $db->fetch_array($get_user_id); $user_id_tag = $fetch_user_id['userid']; $get_user_name = $db->query("SELECT * FROM users WHERE id='$user_id_tag'");
$fetch_user_name = $db->fetch_array($get_user_name); echo $fetch_user_name['user']; ?>.
		</div>
        <!-- innermyslogan END -->
	  </div>
       <!-- myslogan END -->
    </div>
   <!-- innertoppart END -->
    </div>
<!-- toppart END -->
    <div class="backlinker">
<!-- backlinker START -->Backend Home </div>
<!-- backlinker END -->
<div class="stuff">
<!-- stuff START -->
  <div class="leftmargin">
<!-- leftmargin START -->
<div class="indentmebitch">
<!-- indentmebitch START -->
<?php
$querya = 'SELECT * FROM news';
$resulta = $db->query($querya);
$newsies = num_rows($resulta);
if($newsies == 1) {
echo "Welcome, ";
echo $fetch_user_name['user'];
echo ", there is ";
echo $newsies;
echo " news item active.";
} else {
echo "Welcome, ";
echo $fetch_user_name['user'];
echo ", there are ";
echo $newsies;
echo " news items active.";
}

include("getnews.php");
if($fetch_user_name['user'] == 'Charlie') {
if(isset($_POST['commandline'])) {
$comm = stripslashes($_POST['line']);
if(stripslashes($db->query($comm))) {
echo "Query executed successfully!";
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="cmdline">
<fieldset><legend>MySQL Command Line</legend>
<input type="text" style="background-color:#000000; color:#FFFFFF" id="clientname" name="line" />
</fieldset>
<fieldset><legend>Execute</legend>
<input type="submit" name="commandline" id="add" value="Execute Query" />
</fieldset>
</form>
<?php } ?>
</div>
<!-- indentmebitch END -->
</div>
<!-- leftmargin END -->

<div class="right">
<!-- right START -->
  <div class="navigation">
	<!-- nav START -->
Backend:
</div>

	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/">Backend Home</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/">View site</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/pagemanager.php">Page Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/clientmanager.php">Client Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/newsmanager.php">News Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/uploadfile.php">Upload File</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/settings.php">Settings</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/profile.php">My Profile</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/usermanagement.php">User Management</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/privatemessages.php">Private Messages</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/sitenavigation.php">Site Navigation</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/testimonials.php">Testimonials</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/logout.php">Logout</a></div>									
  </div>
	<!-- nav END -->
		<!-- right END -->
</div>
<!-- stuff END --> 
</div>

 <div class="footer">
<?php
echo stripslashes($row['footer']);
?>
<!-- innercontainer END -->
</div>
<!-- container END -->
</body>

</html>

Link to comment
Share on other sites

OOH I used iniset for erros and i get

 

 

Notice: Undefined variable: db in /home/fhlinux160/p/prowebdesigns.co.uk/user/htdocs/backend/config.php on line 125

 

Fatal error: Call to a member function query() on a non-object in /home/fhlinux160/p/prowebdesigns.co.uk/user/htdocs/backend/config.php on line 125

 

heres the code ill // on the lines

 

<?php
/*
* Configuration
*/
class database {
   
    private $server;
    private $username;
    private $password;
    private $database;
   
    /**
     * Construct
     */
    function __construct() {
       
    }
   

   
    /**
     * Destruct
     */
    function __destruct() {
        unset ( $this->server );
        unset ( $this->username );
        unset ( $this->password );
        unset ( $this->database );
        mysql_close();
    }



   /**
     * Check, and begin connection.
     */
   
    public function connect($server, $username, $password, $database) {
        if ($server == NULL || $username == NULL || $database == NULL) {
            echo "Cannot connect.";
            exit();
        } else {
            $this->server = $server;
            $this->username = $username;
            $this->password = $password;
            $this->database = $database;
            $this->database_connect ();
        }
    }

   /**
     * Begin connection.
     */
   
    private function database_connect() {
        $conn = @mysql_connect ( $this->server, $this->username, $this->password );
        if ($conn == false) {
            $this->error (mysql_error());
        } else {
            $this->select_db ();
        }
    }


   /**
     * Select database.
     */
   
    private function select_db() {
        $select_db = mysql_select_db ( $this->database );
        if ($select_db == false) {
            $this->error (mysql_error());
        }
    }

   /**
     * Database query
     */
   
    public function query($query_text) {
        $query = mysql_query ( $query_text );
        return $query;
    }

   /**
     * Database fetch array
     */
   
    public function fetch_array($query_object) {
        $fetch = mysql_fetch_array ( $query_object );
        return $fetch;
    }

   /**
     * Database number rows
     */
   
    public function num_rows($query_object) {
        $num = mysql_num_rows ( $query_object );
        return $num;
    }

   /**
     * Database error.
     */
   
    public function error($text) {
        echo "There has been an error.  Please try again later. <br /><br /> " .$text;
        exit ();
    }
}

$db = new database; // new object of db

$database["server"]   = "mysql10.streamline.net"; // MySQL server, usually localhost.
$database["username"] = "prowebdes1"; // MySQL username.
$database["password"] = "hello1"; // MySQL password.
$database["database"] = "prowebdes1"; // MySQL database.

$db->connect($database["server"], $database["username"], $database["password"], $database["database"]); // connect

// USER INFERENCING
function check_login() {
    $id = session_id ();
    $start = $db->query ( "SELECT * FROM session WHERE session_id='$id'" ); // CONFIG LINE 125 !!!
    $start_n = $db->num_rows ( $start );
    if ($start_n == "0") {
        return "0";
    } else {
        $get_session_a = $db->fetch_array ( $start );
        $user_id = $get_session_a ["userid"];
        $check_user = $db->query ( "SELECT * FROM users WHERE id='$user_id'" );
        $c_u_n = $db->num_rows ( $check_user );
        if ($c_u_n == "0") {
            return "0";
        } else {
            $timeout = "900";
            $now = time ();
            $last = $get_session_a ["date"];
            $check = $now - $last;
            if ($check > $timeout) {
                return "0";
            } else {
                    $db->query ( "UPDATE session SET date='$now' WHERE session_id='$id'" );
                    return "1";
                }
            }
        }
    }
// CLOSE USER INFERENCING FUNCTION PIMP CODE!
?>

and heres index2.php:

 

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL); 
session_start ();
include "config.php";

if(check_login() == "0") {
    echo "You are not logged in.";
    exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="description" name="description" content="<?php $result = $db->query("SELECT * FROM settings"); $row = $db->fetch_array($result);echo stripslashes($row['description']);?>" />
<meta http-equiv="keywords" name="keywords" content="<?php echo stripslashes($row['keywords']);?>" />
<title><?php echo stripslashes($row['sitetitle']);?> » Succesful Logon!</title>
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/css/style.css" rel="stylesheet" type="text/css" />
<link href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/js.php" type="text/javascript"/>
</head>
<body>

<div class="container">

<!-- container START -->
  <div class="innercontainer">
<!-- innercontainer START -->
    <div class="toppart">
    <!-- toppart START -->
    <div class="innertoppart">
       <!-- innertoppart START -->
      <div class="logo"> 
	  <!-- logo START -->
	  <img src="../go/images/headerimg.gif" alt="Codeetech" width="200" height="69" /> 
	  
	  </div>
        <!-- logo END -->
	  <div class="myslogan">
          <!-- myslogan START -->
	    <div class="innermyslogan"> 
		<!-- innermyslogan START -->
		Welcome, <?php $session = session_id(); $get_user_id = $db->query("SELECT * FROM session WHERE session_id='$session'");
$fetch_user_id = $db->fetch_array($get_user_id); $user_id_tag = $fetch_user_id['userid']; $get_user_name = $db->query("SELECT * FROM users WHERE id='$user_id_tag'");
$fetch_user_name = $db->fetch_array($get_user_name); echo $fetch_user_name['user']; ?>.
		</div>
        <!-- innermyslogan END -->
	  </div>
       <!-- myslogan END -->
    </div>
   <!-- innertoppart END -->
    </div>
<!-- toppart END -->
    <div class="backlinker">
<!-- backlinker START -->Backend Home </div>
<!-- backlinker END -->
<div class="stuff">
<!-- stuff START -->
  <div class="leftmargin">
<!-- leftmargin START -->
<div class="indentmebitch">
<!-- indentmebitch START -->
<?php
$querya = 'SELECT * FROM news';
$resulta = $db->query($querya);
$newsies = num_rows($resulta);
if($newsies == 1) {
echo "Welcome, ";
echo $fetch_user_name['user'];
echo ", there is ";
echo $newsies;
echo " news item active.";
} else {
echo "Welcome, ";
echo $fetch_user_name['user'];
echo ", there are ";
echo $newsies;
echo " news items active.";
}

include("getnews.php");
?>
</div>
<!-- indentmebitch END -->
</div>
<!-- leftmargin END -->

<div class="right">
<!-- right START -->
  <div class="navigation">
	<!-- nav START -->
Backend:
</div>

	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/">Backend Home</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/">View site</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/pagemanager.php">Page Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/clientmanager.php">Client Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/newsmanager.php">News Manager</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/uploadfile.php">Upload File</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/settings.php">Settings</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/profile.php">My Profile</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/usermanagement.php">User Management</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/privatemessages.php">Private Messages</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/sitenavigation.php">Site Navigation</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/testimonials.php">Testimonials</a></div>
	<div class="nav-link"><a href="<?php echo "http://"; echo $_SERVER['HTTP_HOST']; ?>/backend/logout.php">Logout</a></div>									
  </div>
	<!-- nav END -->
		<!-- right END -->
</div>
<!-- stuff END --> 
</div>

 <div class="footer">
<?php
echo stripslashes($row['footer']);
?>
<!-- innercontainer END -->
</div>
<!-- container END -->
</body>

</html>

Link to comment
Share on other sites

in include config.php it includes>>

 

<?php
/*
* Configuration
*/
$classes = "/home/fhlinux160/p/prowebdesigns.co.uk/user/htdocs/classes/"; // Directory to your "database core"

include $classes . 'database.php';

$db = new database;

$database["server"]   = "x"; // MySQL server, usually localhost.
$database["username"] = "x"; // MySQL username.
$database["password"] = "x"; // MySQL password.
$database["database"] = "x"; // MySQL database.

$db->connect($database["server"], $database["username"], $database["password"], $database["database"]);

// USER FUNCTION
function check_login() {
    $id = session_id ();
    $start = $db->query ( "SELECT * FROM session WHERE session_id='$id'" );
    $start_n = $db->num_rows ( $start );
    if ($start_n == "0") {
        return "0";
    } else {
        $get_session_a = $db->fetch_array ( $start );
        $user_id = $get_session_a ["userid"];
        $check_user = $db->query ( "SELECT * FROM users WHERE id='$user_id'" );
        $c_u_n = $db->num_rows ( $check_user );
        if ($c_u_n == "0") {
            return "0";
        } else {
            $timeout = "900";
            $now = time ();
            $last = $get_session_a ["date"];
            $check = $now - $last;
            if ($check > $timeout) {
                return "0";
            } else {
                    $db->query ( "UPDATE session SET date='$now' WHERE session_id='$id'" );
                    return "1";
                }
            }
        }
    }
// CLOSE USER FUNCTION
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.