Jump to content

Fetching the Site URL


Dev01

Recommended Posts

You didn't define the function.

 

I'm not sure exactly what you're looking for, but if you're just wanting to use php to get the url or the page where the script is executing, look for what you want in the $_SERVER array (google $_SERVER and read the php manual -- it gives good examples).  Some will give the complete path, some the domain name only, some the script only...etc.

 

For example:

<?php
echo $_SERVER['SERVER_NAME'];
?>

should give you something like www.example.com

therefore...

<?php
$mysite=$_SERVER['SERVER_NAME'];
echo "My website is: $mysite";
?>

should give you something like:

My website is: www.example.com

 

header('Location: login.php'); will forcefully redirect your users to the login.php page.

 

If this is what you want to do, be sure to do this before any output and follow it immediately with exit;

 

 

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.