ss_millionaire
ss_millionaire

Reputation: 429

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...`

Upvotes: 0

Views: 13964

Answers (2)

Arcade116
Arcade116

Reputation: 1

Well, this works for me and this is dynamic too.

$url = $_SERVER['HTTP_HOST'].  '/emailtest'.'/verify.php?email=' . urlencode($email) . "&key=$encode";

Made use of the global SERVER.

Hope this works for you.

Upvotes: 0

ewizard
ewizard

Reputation: 2862

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

Upvotes: 1

Related Questions