Jump to content

How do I display something from index.php on member.php if member.php is...


ethan89

Recommended Posts

included in index.php?  I hope that wasn't confusing.  Here is my complete problem:

 

I have one page called index.php that contains:

 

<?php

$member = substr(dirname($_SERVER['PHP_SELF']), 8); // This is the name of the directory

include 'http://www.EXAMPLE.com/users/member.php'…

?>

 

I have another page called member.php (the one that is included) that contains:

 

<?php echo "$member"; ?>

 

There is only one problem. The above code doesn't work. It won't display $member. How can I fix this?

 

Setting a cookie didn't work. Maybe because member.php is included in index.php and I'm not going from index.php to member.php.

 

Thank you very much for the help!  I appreciate people taking their time to help other people.

#1, if member.php is on the same server as index.php, you don't include a URL

 

include('users/member.php');  //or whatever the path is

 

#2, where do you define $member?

I tried doing user/member.php and /user/member.php and it can never find the directory so I had to do the whole URL.  Do you think this is my problem?  Maybe it's not possible to do it without the whole URL since member.php is in users/ and index.php is in users/*username*/

 

I defined $member in index.php

Oh.. I put member.php in the same folder as index.php just to test that it works and it does.  I guess the http:// was messing it up like you said.  I have a problem though.  I can't put member.php in the same folder as index.php later.  How can I include member.php in index.php without using http://www if it's one folder back?  :-\

Thanks for your help, Abra.  It turns out all I needed to do was change http://www.EXAMPLE.com/users/member.php to ../member.php.

 

I love it when there is such a simple solution to a seemingly huge problem  :D

Could you tell why you can't move files from folders within the system? this seems rather odd, or are you just using ftp to update? in that case, drag the file to your desktop, browse to the right folder and drop it in there.

Good thing you found a work around :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.