hellonoko Posted October 26, 2008 Share Posted October 26, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/ Share on other sites More sharing options...
R4nk3d Posted October 26, 2008 Share Posted October 26, 2008 i can use them fine. try and go to the link of the menu.php file and add ?user=bob onto the end to see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675199 Share on other sites More sharing options...
hellonoko Posted October 26, 2008 Author Share Posted October 26, 2008 Yes that is what I am saying I do and DOES work. If I go to menu.php?user=bob it displays bob. If i go to index.php?user=bob it display nothing but does displays bobs files. Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675202 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 And because we are physic we know your code all ready ? Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675212 Share on other sites More sharing options...
R4nk3d Posted October 26, 2008 Share Posted October 26, 2008 And because we are physic we know your code all ready ? haha, yeah, some code would be nice Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675213 Share on other sites More sharing options...
hellonoko Posted October 26, 2008 Author Share Posted October 26, 2008 echo $_GET['user']; Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675215 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 so thats the whole code? Also have you made sure it is on the index page? Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675218 Share on other sites More sharing options...
hellonoko Posted October 26, 2008 Author Share Posted October 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675224 Share on other sites More sharing options...
DeanWhitehouse Posted October 26, 2008 Share Posted October 26, 2008 I don't think you can do it like that, i don't think you can include files and use $_GET or $_POST in them. Why not have an if statement instead in the main page? Quote Link to comment https://forums.phpfreaks.com/topic/130196-using-_get-in-included-files/#findComment-675226 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.