Jump to content


Photo

how to define the server root?


  • Please log in to reply
2 replies to this topic

#1 AeonE

AeonE
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 March 2006 - 01:49 PM

guys, I'have some question to ask

eCom
| - eCom.php
|
| -Admin
| |- Admin.php
|
|- User
| |- User.php


where eCom is my TOP directory and Admin/user is a folder under eCom directory,

here's my question, how do I link those 3 together without repeating the hyperlink code? assuming in eCom.php I have created a hyperlink to Admin like this <?php echo "<a href=\"Admin/Admin.php>Admin Page</a>" ?> and of course my Home is <?php echo "<a href=\"eCom.php>Home</a>" ?>

so it looks like this in eCom.php,

<?php echo "<a href=\"eCom.php>Home</a>" ?>
<?php echo "<a href=\"Admin/Admin.php>Admin Page</a>" ?>
<?php echo "<a href=\"User/User.php>User</a>" ?>


and for Admin.php,

<?php echo "<a href=\"../eCom.php>Home</a>" ?>
<?php echo "<a href=\"Admin.php>Admin Page</a>" ?>
<?php echo "<a href=\"../User/User.php>User</a>" ?>


it works to link them together but...
I want a simple method that allows you to only need to define SERVER root to access files in that root, how you do that? meaning that I can remove this:

<?php echo "<a href=\"../eCom.php>Home</a>" ?>
<?php echo "<a href=\"Admin.php>Admin Page</a>" ?>
<?php echo "<a href=\"../User/User.php>User</a>" ?>


for my admin.php , and only add include ('../eCom.php'); inside my Admin.php

what should I write in my eCom.php , please help!!!

many thanks

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 March 2006 - 02:04 PM

you can always make a file say configs.php. And in the file you can set up your pages

$ecom = "http://ecom.com/ecom.php";
$admin = "http://ecom.com/admin/admin.php";
$users = "http://ecom.com/users/user.php";

then on the top of each page you can just put in

require('configs.php');

Then you can reference each page with the variable

<?php echo "<a href=\"$ecom\">Home</a>" ?>
<?php echo "<a href=\"$admin\">Admin Page</a>" ?>
<?php echo "<a href=\"$users\">User</a>" ?>

And if you need to add some parameters to it then you can do it like this

<?php echo "<a href=\"$ecom\">Home</a>" ?>
<?php echo "<a href=\"$admin\">Admin Page</a>" ?>
<?php echo "<a href=\"$users?id=2\">User</a>" ?>

There are other ways to get the document root but you would still have to enter in the folders after the root.

Ray


#3 AeonE

AeonE
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 23 March 2006 - 05:56 PM

yeahhhh man it works,

thx alot




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users