leedude Posted August 6, 2006 Share Posted August 6, 2006 Im trying to pass a get variable to an include called note.php:include "note.php?title=note1";This causes the note to not show up at all.I have tried going to note.php?title=note1 in a browser and it works fine.I have also tried include "note.php";. This creates a blank note on the page(it works).Is there some special function i have to use to pass variables to an include?Please help. Quote Link to comment https://forums.phpfreaks.com/topic/16733-passing-getpost-to-include/ Share on other sites More sharing options...
wildteen88 Posted August 6, 2006 Share Posted August 6, 2006 You cannot pass url parameters when including files, they will be ignored. Quote Link to comment https://forums.phpfreaks.com/topic/16733-passing-getpost-to-include/#findComment-70343 Share on other sites More sharing options...
ignace Posted August 6, 2006 Share Posted August 6, 2006 what wildteen88 said + try the following code[code]<?phpif (!@$_GET['title']) { // if the following line returns error's then comment the line, and uncomment the second header('Location: ' . $_SERVER['PHP_SELF'] . '?title=note1'); //echo "<script>window.location.href='" . $_SERVER['PHP_SELF'] . "?title=note1';</script>";}include('note.php');//now the get/post variable should be available in your note.php file// note.phpecho $_GET['title'];?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16733-passing-getpost-to-include/#findComment-70344 Share on other sites More sharing options...
wildteen88 Posted August 6, 2006 Share Posted August 6, 2006 [quote author=wildteen88 link=topic=103207.msg410850#msg410850 date=1154893010]You cannot pass url parameters when including files, they will be ignored.[/quote]I forgot to mention this earlier. Instad of parsing the url parameters in the include statement you should use them on the page that is including the file. Quote Link to comment https://forums.phpfreaks.com/topic/16733-passing-getpost-to-include/#findComment-70346 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.