rofl90 Posted March 19, 2008 Share Posted March 19, 2008 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.. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Ooh, the wrong password gives an error, but the right password just refreshes. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Update: The session query is working i checked in phpmyadmin. Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 19, 2008 Share Posted March 19, 2008 what is your current page name? i mean the pages that just refresh Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 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 } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 19, 2008 Share Posted March 19, 2008 <?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.. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 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 Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 ooh I think i fixed that bug with deleting the or die(mysql_error()) because its already in the function but now index2.php isn't working llemme see if i can fix that Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 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> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 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> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 What the hell! I put them into the same file it specifically says $db = new database; and it says call to undefined variable!!?!?!?!? Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 This is so wierd, is it maybe something to do with them being in the same file? It's random as hell.. I mean, it shouldn't be doing this, $db is definitely defined, and so is check_user() Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Is there any functions i can use to verify it? Quote Link to comment Share on other sites More sharing options...
peranha Posted March 19, 2008 Share Posted March 19, 2008 After setting variable, you can echo it where you want it to go, and if it echos what it is supposed to, it is set. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 i tried to use the variable as the class as $db = new database; then $db->query(); but it says its undefined and when i try to call a function it sys thats undefined too.. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Uggh anyone have any idea? This is so strange. ??? ??? Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Is the include path good? Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 19, 2008 Share Posted March 19, 2008 can you give us the link of that page? Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 http://www.codeetech.com/backend/index2.php it only shows the errors. EDIT new link Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 I'm off to sleep, if anyone finds a fix please pm me.Thanks - Charlie Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 19, 2008 Share Posted March 19, 2008 $db is not an object on index2.php I havent seen anything like $db = new classhere; to use all the functions and var inside that class Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 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 ?> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Is it to do with the new class is it the right syntax? Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 19, 2008 Author Share Posted March 19, 2008 Ergh, god this is annoying, the class is correct syntax right? is the function? :S Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.