Jump to content

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.

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.