Search code examples
phpbase-url

How to properly set a baseurl on localhost


I have a php file verify.php in a folder called emailtest on localhost. I'm implementing an email verification script. But i'm having issues with the activation url that is emailed after registration. Take a look:

define("BASE_PATH", dirname('http://localhost:8888/'))

$url = BASE_PATH . '/emailtest'.'/verify.php?email=' . urlencode($email) . "&key=$encode";

In the email sent, i'm getting a link that looks like this(which is unopenable):

    `"http:/emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a..."`

But what i really want is this

`http:localhost:8888/emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a...`

How can i properly set the url.?

UPDATE Just for future reference i mistyped the link, should be:

`http://localhost:8888//emailtest/verify.php?email=lexon4ril%40yahoo.com&key=58a9a...`

Solution

  • Try define("BASE_PATH", "http://localhost:8888") - I don't think you need to use dirname() function.