I am stuck using include () function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

I am stuck using include () function

Post by harsha »

I have created two pages

index.php

this page is the main page. and i have included

include(jawab.php?a=default) in this page

---------------------------------------------
jawab.php
in this page i have used
$_SERVER["PHP_SELF"];
in the anchor tag

I have the problem here.

when i click the anchor in the index.php the jawab.php is not opening in freshly instead it is opened there it self.

and the $_SERVER["PHP_SELF"] is taking value
index.php instead of jawab.php when include as mentioned above.

how can i overcome this problem.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Try This Instead

Post by thomas777neo »

Hi

First of all I don't think you can send variables through the include statement. To get around this you could do this:

Code: Select all

$a="default";

include("whatever.php"); //note the syntax
(this would automatically include the $a variable)

But you wanted the page you include to open freshly, thus you could use the header function.

Code: Select all

$header = "Location: http://localhost/your_site/whatever.php?val=" . $val . "&reportname=" . $reportname. "&parm=" .$parm;
header("$header");
This should work a bit better

Cheers 8)
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Re: I am stuck using include () function

Post by m3rajk »

harsha wrote:I have created two pages

index.php

this page is the main page. and i have included

include(jawab.php?a=default) in this page

---------------------------------------------
jawab.php
in this page i have used
$_SERVER["PHP_SELF"];
in the anchor tag

I have the problem here.

when i click the anchor in the index.php the jawab.php is not opening in freshly instead it is opened there it self.

and the $_SERVER["PHP_SELF"] is taking value
index.php instead of jawab.php when include as mentioned above.

how can i overcome this problem.
$_SERVER[PHP_SELF] is working perfectly. it's your understanding of it that is the issue.

it can only refer to the page that it is in.

same thing with your include issuetry bookmarking http://www.php.net

the seardch function feature should have explained the include issue
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Post by harsha »

Thank you very much i fixed the problem the script works fine and perfect.

harsha
Post Reply