Http://localhost in php script?

I have a blog (WordPress) and a forum (phpBB). I am using a plug in to try to integrate user log in for both.

The script calls for -

if ( $userdata[‘session_logged_in’] )
$u_login_logout = ‘…/wordpress/wphpbb-login.php?action=logout&redirect_to=http://localhost’. $_SERVER[‘REQUEST_URI’] . ‘&sid=’ . $userdata[‘session_id’];//‘login.’.$phpEx.’?logout=true&sid=’ . $userdata[‘session_id’]
$l_login_logout = $lang[‘Logout’] . ’ [ ’ . $userdata[‘username’] . ’ ]’;
$u_login_logout = ‘…/wordpress/wphpbb-login.php?&redirect_to=http://localhost’. $_SERVER[‘REQUEST_URI’]; //‘login.’.$phpEx;
$l_login_logout = $lang[‘Login’];

I know that normally you have to change “localhost” to “

Would this apply here also?

Edited: Oops! I didn’t look at the code closely enough, and gave you a “bum” answer - I’m sorry! :frowning: No, it doesn’t. In the case of defining your MySQL host, you need to replace “localhost” with the appropriate host for your database. In this instance, “localhost” should be replaced with an environment variable to help define paths/urls and, as such, should not have the the name of your MySQL database host substituted for it, rather the varible to represent the path of your server - what Atropos7 said


Yes. Obviously one cannot use localhost as the hostname in the URL. You have two options. You can explicitly specify the hostname using your own variable, or implicitly specify it using the superglobal $_SERVER.

For example, one might want to do this:

$redirect_hostname = $_SERVER[‘SERVER_NAME’] ;
$redirect_path = $_SERVER[‘REQUEST_URI’];
$redirect_url = ‘http://’ . $redirect_hostname . $redirect_path;

$u_login_logout = ‘…/wordpress/wphpbb-login.php?action=logout&redirect_to=’ . $redirect_url . ‘&sid=’ . $userdata[‘session_id’];

Edit: It should be obvious but $redirect_hostname should be the hostname of your website.

:cool: [color=#6600CC]Atropos[/color] |

How do you know it should be instead of Just wondering.

Good catch on my “bad” advice there… I didn’t look at the code closely enough, and have edited my post, but I believe in this instance if the OP chooses to define the path explicitly, he needs to use the path of his http server, not his mysql server…or am I completely missing this? (which is certainly possible!)


I should have stated I would need “dummied” down answers. :slight_smile: The instructions for the plug in said to use the absolute path.

You said I would need to replace “localhost” with the host for my database.

When I created the database, the “hostname” was prepopulated with “”. I did not change this.

So, would the path be - ?

I’m sorry for the confusion…I think what should go there is either an environment variable that contains your domain, or actual “hardcoding” in your domain, not your database host.

I think what should go in there is:

I believe the code is to handle to routing of pages to your site, not interaction with your database (note the other messages in this thread).

What pluy-in are you trying to install?(name - link, etc.)? I’ll go take a look and get a better idea of what is involved if you would like for me to.


You’re right, he does need to specify the hostname of a HTTP server, in particular the one hosting his web site. I’ve edited my post as well.

I assumed OP just needed clarification that he needs to modify the script to use a different hostname. I interprated his statement as an observation that one cannot use localhost based on the documentation or experience with using databases.

:cool: [color=#6600CC]Atropos[/color] |

I’m using wphpBB-Login v0.12. It can be found at -

I’ll try your suggestion. I know just enough to be dangerous.

I used the path to my database earlier and the forum page was OK, but my main site page was blank.

Thanks for your help.

No probelm - we kinda “borked” up giving you a clean-cut answer on your question, and I apologize. I’ll go over an take a look at the plug-in, though I think , especially from you last post, that you will be “good to go” with your main site url in place of localhost.

Please post back and let us know how it goes, ok? :wink:


Thanks, I will.

I think there are other adjustments I’ll need to make. I can’t seem to find one set of instructions that gives all the same information.

I have done everything that came with the plug in zip, but I found some additional instructions on his website.

I’m headed to update my “localhost” mistake now. didn’t work.

My main site is still blank.

I"m going to restore everything back to the way it was and see if I can figure it out from a “clean” start.

I’m sorry to hear that…(you did clear all your caches, right?) I just went to your site, and it looks good; you must have already “undone it all”.

I’ looking at the plug-in now, and will post back if I find anything helpful…


I’m giving up. At least for tonight. I put everything back like it was.

This is what the instructions with the plug in said to do -

I kept getting a blank index page.

  1. Done
  2. Done
  3. Done
  4. No clue!
  5. Done
  6. Done
  7. Done
  8. Done
  9. Done
  10. Didn’t work.
  11. Done - this was my “localhost” question.
  12. Not yet!

But, on his website, I also found -

The find function instructions weren’t with the plug in I downloaded.

So, I’ll try again when my head quits hurting.

I understand…I just spent about 30 minutes digging through the site for the plug-in, and now my head is starting to hurt too :frowning: . The documentation is a “mess”, and I’m not real thrilled that installing this plug-in requires editing the “core” files of both phpbb and wp. - that should make upgrades (especially important with PhpBB, given its security history!) a real “joy” (not!).

I’m not 100% sure I yet understand a lot of what I’ve read over there…and I know I’m not sure where the code you supplied was from (wp or phpbb, or the plug-in) - I am 100% sure that the installation seems to be pretty convoluted.

If you feel like giving it a try another time, whay don’t you start a new thread, or maybe you can find someone over on the support forum who has installed this puppy on Dreamhost.

It appears from some of the discussion on the author’s site that mod_security could be impacting the install also, and that is the “Extra Web Security” check-box setting option for domains (see Edit Domain in the Control Panel).

All in all, not encouraging indeed - and I don’t have a spare PHPBB and WP installation laying around to test it with conveniently.

Who knows, maybe it will all look better in the morning…