wmguk Posted December 10, 2008 Share Posted December 10, 2008 Hey, I currently include a file called audit.php on all my php pages. <?php $user = $_SESSION['username'] ; include ("connection.php"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db($db, $con); $user = $_SESSION['username'] ; $pageurl = $_SERVER['REQUEST_URI']; mysql_query("INSERT INTO audit (user, pageurl) VALUES ('$user', '$pageurl');"); ?> however the $pageurl just shows http://www.domain.co.uk/audit.php and not the page that is including audit.php how can i specify the main page, not the included page? Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/ Share on other sites More sharing options...
dennismonsewicz Posted December 10, 2008 Share Posted December 10, 2008 try $pageurl = $_SERVER['PHP_SELF]; Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711525 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Post some code that includes audit.php Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711527 Share on other sites More sharing options...
wmguk Posted December 10, 2008 Author Share Posted December 10, 2008 try $pageurl = $_SERVER['PHP_SELF]; Hi, just tried that and get the same - its the audit.php file, not the main page Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711531 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Post some code that includes audit.php ??? If you want to help solve this issue I would post the top part of the file that include audit.php Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711535 Share on other sites More sharing options...
wmguk Posted December 10, 2008 Author Share Posted December 10, 2008 Post some code that includes audit.php ??? If you want to help solve this issue I would post the top part of the file that include audit.php sorry, i did try but phpfreaks wouldnt let me repost quickly then IE crashed.... anyway: <?php session_start(); if (!isset($_SESSION['username'])) { header('Location: http://www.domain.co.uk/admin'); exit; } $name = $_SESSION['name'] ; $admin = $_SESSION['admin']; $adminlevel = $_SESSION['adminlevel']; ?><!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> <?php include ("http://www.domain.co.uk/admin/scripts/audit.php"); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>domain</title> <META NAME="keywords" CONTENT="domain"> <META NAME="description" CONTENT="domain."> <link href="../domain.css" rel="stylesheet" type="text/css" /> <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" /> <!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable --> </head> <body> Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711537 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Why are you including the URL? <?php include ("/admin/scripts/audit.php"); ?> Should work given that is the right spot in the file structure. If that does not work try this: <?php include ($_SERVER['DOCUMENT_ROOT'] . "/admin/scripts/audit.php"); ?> Including it as a webpage, the webpage does not know it is being included, so it is set to audit.php. The above will set it to the page it is included on. Quote Link to comment https://forums.phpfreaks.com/topic/136374-_server-variable-issue/#findComment-711541 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.