How to link to files in a directory?

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
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

How to link to files in a directory?

Post by davidprogramer »

Ok. The following would work but I can't pass globals this way:

Code: Select all

<a href=modules/League/includes/file.php></a>
This however is what I need:

Code: Select all

<a href=modules.php?name=League&file=includes/file.php&variable=value></a>
or something similar, how would I go about doing this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're trying to include a file based on URL variables?
Useful Posts wrote:• Proper use of $_GET with includes: $_GET and include
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

Post by davidprogramer »

no, I mean, well...maybe...

I am trying to pass variables in an URL to a different page, and $GET them on the destination.

I can't use include(file.php) because I still wont be able to pass variables.


This:

Code: Select all

echo "<td nowrap><center><a href=javascript:popUpPermissions('modules.php?name=League&file=includes/clan_hq/edit_permissions.php&rank=$i')>[ Edit ]</a></center></td>";
doesnt work.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You can "pass" variables to another script you include.

Code: Select all

// one.php
$foo = 'hi!';

include 'two.php';

Code: Select all

// two.php

echo $foo;
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

Post by davidprogramer »

But it is going to be a popup, it wont be in the same page.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

modules.php can include "edit_permissions.php" passing any other variables it has along with it. That's what it appears you're building. However I'd recommend not being able to pass directory tree information in the query.. maybe a coded name or something.
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

Post by davidprogramer »

Yeah, I'll encrypt all the variables. My only problem is getting the variables from page1 to popuppage2. :? If I include it, wouldnt that just put popuppage2 inside page1?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're not including it on the current page. You're including the file on the page the popup will call, modules.php.
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

Post by davidprogramer »

Now im confused lol. The popup wont call any other pages. I am going to put scripts on the popup. The scripts will depend on one variable passed from the first page. I sort of understand what you are saying, but how would I include the page and get the variable without running the page that the variables are on?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your popup is referencing a page, modules.php. It's being sent a get variable "file" that references another page.
davidprogramer
Forum Commoner
Posts: 64
Joined: Mon Nov 28, 2005 6:11 pm

Post by davidprogramer »

maybe i dont understand what you mean by include. The only include I know is :

Code: Select all

include("file.php");
which would call file.php, but would also run it right there on the spot.

Is this the same include you are talking about?
Post Reply