Here's the issue.
All the pages on my website have a form. When a user clicks on "Submit" it sends them to another page. However, since these pages can reside either in the root directory or can be down a level or two in another subdirectory, the "action" part of the form has to have the path info.
I tried using getenv('DOCUMENT_ROOT') and then I'd concatenate the name of the file. While this works fine, however, if a user goes to view the source of the file they see a path something like "usr/etc/httpd/mydomain...../mysubdir/myfile.php"
The question is, how can I dynamically generate the proper path without showing the user the entire directory tree? OR, am I getting worried over nothing.
TIA for your help. Everyone here has been quite helpful.
Jeff
Relative Paths & Document Root
Moderator: General Moderators
So where is the form relative to the script you want to send the data to? Is it always aimed at the same script? If so then why not make it point to http://www.yoursite.com/thetarget.php or something similar?
Yes...but...
The only problem I see with that solution is that it is tied to a particular domain.
Thanks anyway for the suggestion.
Jeff
Thanks anyway for the suggestion.
Jeff
Predefined Variables
Use $SERVER_NAMEJeffS wrote:The only problem I see with that solution is that it is tied to a particular domain.
The name of the server host (domain) under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Predefined Variables
$_SERVER['SERVER_NAME'] (for PHP version 4.1 or above) or $HTTP_SERVER_VARS['SERVER_NAME'] (for PHP version 4.0.6 or below) would be better.Kriek wrote:Use$SERVER_NAME
Mac
Tried this -> $_SERVER['SERVER_NAME']
I tested this:
<?php echo $_SERVER['SERVER_NAME'] ?>
and got this: 127.0.0.1
That's not right, is it?
Jeff
<?php echo $_SERVER['SERVER_NAME'] ?>
and got this: 127.0.0.1
That's not right, is it?
Jeff
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Correct!
That's what I thought. I just assumed that it would show me the IP address of the machine itself (which is completely different from the 127....).
Looks like this problem is solved!!
Thanks so much for your time and patience.
Jeff
Looks like this problem is solved!!
Thanks so much for your time and patience.
Jeff