Ok guys.... Almost there....
I managed to load the index page now and i have my login screen. Problem is when i enter my details it just takes be back to the login (index.php) page again...
Its almost as if it can see the database, but when queried nothing happens.
I deleted the inc folder which contains the global.php file. And when this was missing from the htdocs folder the index.php loaded but the username and password were missing. So its looking for the correct file (global.php)
This is the global file: - any ideal?
<?
// ##### Configuration #####
#db connection info
$db_name = "mydb";
$db_username = "user";
$db_password = "pass";
$db_server = "localhost";
// ##### DB Connection #####
define( 'APP_URL', 'http://localhost' );
define( 'CLASS_URL', APP_URL.'/classes' );
define( 'INCLUDE_URL', APP_URL.'/inc' );
define( 'IMAGE_URL', APP_URL.'/images' );
define( 'PDF_URL', APP_URL.'/pdf' );
define( 'APP_PATH', '');
define( 'CLASS_PATH', APP_PATH.'classes' );
define( 'FORM_PATH', APP_PATH.'forms' );
define( 'INCLUDE_PATH', APP_PATH.'inc' );
define( 'PAGE_PATH', APP_PATH.'pages' );
define( 'UPAGE_PATH', APP_PATH.'users/pages' );
define( 'APAGE_PATH',APP_PATH.'admin/pages' );
define( 'SITE_NAME', 'localhost');
define( 'ENC_KEY', 'asdfasdfasdf...');
#connect to the MySQL database
$conn = mysql_connect($db_server,$db_username, $db_password);
#select the db
mysql_select_db($db_name, $conn);
// ##### No Caching ####
header ("Expires: Thurs, 2 Jun 2005 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
#Set Date Variables
$day = date("d");
$month=date("m");
$year=date("Y");
$hour=date("H");
$minute=date("i");
#Global Shop variables
$vat_rate = "17.5";
function session_defaults()
{
$_SESSION['logged'] = false;
$_SESSION['uid'] = 0;
$_SESSION['username'] = '';
$_SESSION['cookie'] = 0;
$_SESSION['remember'] = false;
}
if (!isset($_SESSION['uid']) ) { session_defaults(); }
class User
{
var $db = null; // PEAR::DB pointer
var $failed = false; // failed login attempt
var $date; // current date GMT
var $id = 0; // the current user's id
function User(&$db)
{
$this->db = $db;
$this->date = $GLOBALS['date'];
if($_SESSION['logged']) {$this->_checkSession(); }
elseif ( isset($_COOKIE['mtwebLogin']) ) {$this->_checkRemembered($_COOKIE['mtwebLogin']); }
}
function _checkLogin($username, $password, $remember)
{
$username = $this->db->quote($username);
$password = $this->db->quote(md5($password));
$sql = "SELECT * FROM staff WHERE username = $username AND password = $password";
$result = $this->db->getRow($sql);
if ( is_object($result) )
{
$this->_setSession($result, $remember);
return true;
}
else
{
$this->failed = true;
$this->_logout();
return false;
}
}
function _setSession(&$values, $remember, $init = true)
{
$this->id = $values->id;
$_SESSION['uid'] = $this->id;
$_SESSION['username'] = htmlspecialchars($values->username);
$_SESSION['cookie'] = $values->cookie;
$_SESSION['logged'] = true;
if ($remember) {$this->updateCookie($values->cookie, true); }
if ($init)
{
$session = $this->db->quote(session_id());
$ip = $this->db->quote($_SERVER['REMOTE_ADDR']);
$sql = "UPDATE member SET session = $session, ip = $ip WHERE id = $this->id";
$this->db->query($sql);
}
}
function _checkSession()
{
$username = $this->db->quote($_SESSION['username']);
$cookie = $this->db->quote($_SESSION['cookie']);
$session = $this->db->quote(session_id());
$ip = $this->db->quote($_SERVER['REMOTE_ADDR']);
$sql = "SELECT * FROM member WHERE (username = $username) AND (cookie = $cookie) AND (session = $session) AND (ip = $ip)";
$result = $this->db->getRow($sql);
if (is_object($result) ) { $this->_setSession($result, false, false); }
else { $this->_logout(); }
}
}
function currency_display($number) {
$number2display = number_format($number, '2', '.', '');
return $number2display;
}
#Weight Conversion Function
function convWeight($conv_weight,$conv_unit)
{
switch ($conv_unit)
{
case "kg":
return sprintf("%1.0f",($conv_weight / 0.454008898574412));
break;
case "s":
return sprintf("%1.0f",($conv_weight / 0.071494163451271));
break;
case "lb":
return sprintf("%1.0f",$conv_weight);
break;
default:
return "Error!";
}
}
?>