Jump to content

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/16733-passing-getpost-to-include/
Share on other sites

what wildteen88 said + try the following code

[code]
<?php
if (!@$_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.php
echo $_GET['title'];
?>
[/code]
[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.
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.