Jump to content

php links don't work


alejandro52

Recommended Posts

I have some links created dynamicaly with php. But i have the following problem. When i am in the root folder ieg. localhost/myPage/index.php the links work fine because they link in a file named entry.php. but when i am in a folder ieg. localhost/myPage/users/authors.php and i click the links they try to go to  localhost/myPage/users/entry.php and i want them to link not inside the folder but to the root folder localhost/myPage/entry.php.

Link to comment
Share on other sites

Can you understand what i am saying? The links go to <a href="entry.php"/> wehre entry.php is located inside localhost/mypage/ and when i click on thef from a file inside localhost/mypage/anotherfolder/index.php the link won't work cause it takes me to localhost/mypage/anotherfolder/entry.php and i want to go to localhost/mypage/entry.php

Link to comment
Share on other sites

  echo "<div><a href=\"auth.php?auth_id=".$row["auth_id"]. "\" class='sidebar_name'>".$row["fname"]. " " .$row["lname"]."<a/><br/>";

This takes me to localhost/mypage/auth.php?auth_id=".$row["auth_id"].  this is a sidebar menu , o use it with a dreamweaver template throughouth the site. when i click it from /localhost/mypage/user/staff.php it takes me to /localhost/mypage/user//auth.php?auth_id=".$row["auth_id"] where it should take me to /localhost/mypage/auth.php?auth_id=".$row["auth_id"]

Link to comment
Share on other sites

mraza, may i ask if that is a secure way, or does it has the same downside as a $_SERVER var.

I really don't know so i thought i ask :) thanks for this btw ::)

please read more about getenv at here http://php.net/manual/en/function.getenv.php

and ofc is secure as per my knowledge

a comment from php.net

This function is useful (compared to $_SERVER, $_ENV) because it searches $varname key in those array case-insensitive manner.

For example on Windows $_SERVER['Path'] is like you see Capitalized, not 'PATH' as you expected.

So just: <?php getenv('path') ?>

 

Link to comment
Share on other sites

SO if i have my site say at http://www.mysite.com it yould be ok to name my url link href=" http://www.mysite.com/entry.php' or would this slow the site responce?

 

Yeah that's perfectly fine, it won't make any difference with speed. All it is a path so that the browser knows where to go. I'm not sure what mraza's suggesting with using the server's document root, but $_SERVER['DOCUMENT_ROOT'] (which ever way it's accessed) is the server's file system path to the document root, not the browser's / publically accessible path.

Link to comment
Share on other sites

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.