Current time: 05-26-2015, 06:38 PM Hello There, Guest! (LoginRegister)

Post Reply 
http://localhost in php script?
11-24-2006, 03:26 PM
Post: #1
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'] . ' ]';
}
else
{
$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 "mysql.example.com"

Would this apply here also?
Find all posts by this user
Quote this message in a reply
11-24-2006, 04:17 PM
Post: #2
http://localhost in php script?
Edited: Oops! I didn't look at the code closely enough, and gave you a "bum" answer - I'm sorry! Sad 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
.

--rlparker
Find all posts by this user
Quote this message in a reply
11-24-2006, 05:47 PM
Post: #3
http://localhost in php script?
Quote:I know that normally you have to change "localhost" to "mysql.example.com"
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 Atropos | openvein.org
Visit this user's website Find all posts by this user
Quote this message in a reply
11-24-2006, 06:05 PM
Post: #4
http://localhost in php script?
How do you know it should be mysql.example.com instead of http://www.example.com? Just wondering.

tor.eff.org
Visit this user's website Find all posts by this user
Quote this message in a reply
11-24-2006, 06:23 PM
Post: #5
http://localhost in php script?
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!)

--rlparker
Find all posts by this user
Quote this message in a reply
11-24-2006, 07:03 PM
Post: #6
http://localhost in php script?
I should have stated I would need "dummied" down answers. 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 "mysql.ylice.net". I did not change this.

So, would the path be - http://www.ylice.net/mysql.ylice.net/ ?
Find all posts by this user
Quote this message in a reply
11-24-2006, 07:25 PM
Post: #7
http://localhost in php script?
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.
Quote:So, would the path be - http://www.ylice.net/mysql.ylice.net/ ?
I think what should go in there is:

http://www.ylice.net/

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.

--rlparker
Find all posts by this user
Quote this message in a reply
11-24-2006, 07:29 PM
Post: #8
http://localhost in php script?
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 Atropos | openvein.org
Visit this user's website Find all posts by this user
Quote this message in a reply
11-24-2006, 07:31 PM
Post: #9
http://localhost in php script?
I'm using wphpBB-Login v0.12. It can be found at - http://www.happypoet.com/hackery/wphpbb-login/

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.
Find all posts by this user
Quote this message in a reply
11-24-2006, 07:38 PM
Post: #10
http://localhost in php script?
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

--rlparker
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: