Jump to content

using $_GET[] in included files.


hellonoko

Recommended Posts

I have a $_GET variable 'user' in the query string that I use am using to display a certain users files.

 

index.php?user=bob

 

I have two files: menu.php and index.php 

 

In the menu.php file I am trying to use $_GET['user']; to display a line that says: View files from [and the user name here]

 

Then in index.php the same $_GET variable is used to choose what files are displayed.

 

The index.php usage works and when I call menu.php on its own it works.

 

But when I use  menu.php as an include of index.php the $_GET variable will not work in menu.php

 

Can I not use $_GET variables in include files?

Link to comment
https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/
Share on other sites

Haha no but pretty much.

 

<html>
<head>
<link href="http://www..com/styles.css" rel="stylesheet" type="text/css" />

<script language="javascript"> 
  function toggle_it(itemID){ 
      // Toggle visibility between none and inline 
      if ((document.getElementById(itemID).style.display == 'none')) 
      { 
        document.getElementById(itemID).style.display = 'inline'; 
      } else { 
        document.getElementById(itemID).style.display = 'none'; 
      } 
  } 
</script> 

</head>
<body>


<?php

echo $_GET['user'];

echo '<table width="100%" align="center" border="0">';
echo "<tr>";
echo '<td bgcolor="#FFFFFF">';

echo "<span class=red_menu>Hello: $_SESSION[login] </span>";
echo '<span class=black_menu><a href="http://www..com/flashupload2/">Upload</a></span>';
echo "<span class=black_menu> | </span>";
echo '<span class=black_menu><a href="http://www..com/REPOSITORY/">Download</a></span>';
echo "<span class=black_menu> | </span>";
echo '<span class=black_menu><a href="http://www..com/flashupload2/logout.php">Logout</a></span>';
echo "<span class=black_menu> Viewing uploads from: ";
echo $display;
echo "</span>";

echo "</td>";
echo "</tr>";
echo "</table>";


?>

 

Works when called on its own. Fails when used as an include of index.php and when I say fails i mean just echos empty.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.