Jump to content

$_SERVER Variable issue?


wmguk

Recommended Posts

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?

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

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.