PDA

View Full Version : Including PHP from another server


Tigga
06-13-2002, 06:09 AM
I am currently using vbulletinhost to host my message board, and having the rest of my site hosted through a different service. I've receintly started playing with vBindex and would like to incorporate a lot of the features from it on most of the pages on my site. Basically I'd like to have the login box, online users, and a few other things in column on the left side of every page of my main site. The only problem is the main pages of my site are on the other server and I can not figure out a way to include a file from the vBulletinhosting server on that one. Does anyone know how I could do this using PHP, SSI, or anything else besides frames? If anyone could give me some help with this it would be much appreciated.

Spread Peace,
Brian

Admin
06-13-2002, 06:27 AM
You can only include the output of the script, not the actual code.

With PHP:
include('http://www.yoursite.com/path/to/file.php');
SSI:
<!--#include file="http://www.yoursite.com/path/to/file.php" -->

Tigga
06-14-2002, 03:17 AM
Well either you're a genius or I'm an idiot. I think I'll just stick with calling you a genius. ;)
I tried your suggestion with PHP and it worked fine. I had actually tried that before but I guess I did something wrong becuase I could not get it to work. Either way it works great now. Thanks for the help FireFly! :)

Tigga
06-14-2002, 04:05 AM
Hmmm... Actually everything seemed to work well, but now I'm having one other slight problem. It's including the file from my message board server on my main server, but it won't seem to let a user log in from that page or show their info if they are logged in. I have it set up so that if the user is not logged in it shows the log in boxes and if the user is logged in it should show a welcome message, avater, new pm's, and etc. It shows the logincode, but will not seem to show the welcome message after I try logging in. Is this because it's on a different server, or am I just forgetting to do something? If FireFly or anyone has any idea's it would be appreciated. Oh, here's a link to the site that I am trying this on - http://plurplanet.com/new. The main page in the bottom frame is run from the message board server and works fine. Then if you click on "Pictures" in the top frame it will bring up the page I'm trying to use on my main server. Also, here's the coding I'm using...

=============================
Pictures Index Page
=============================

<?php

include('http://vforum.plurplanet.com/include.php');

?>

<TABLE WIDTH=100% CELLSPACING=2>
<TR><TD COLSPAN=5><CENTER><B><FONT FACE="Verdana,Arial,Helvetica" SIZE=2>2002</FONT></CENTER></B><HR></TD></TR>
Etc... Just the HTML from the rest of the page.

=============================
The Includes Template
=============================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<!-- end no cache headers -->
<meta name="keywords" content="vbulletin,forum,bbs,discussion">
<meta name="description" content="$bbtitle">
<title>$bbtitle - powered by vBulletin</title>
$homeheadinclude
</head>
<body TEXT="#D1D1D1" BACKGROUND="http://www.plurplanet.com/images/graphics/background.jpg" BGPROPERTIES="FIXED">
<TABLE WIDTH=100% CELLSPACING=10><TR ALIGN=LEFT VALIGN="TOP"><TD WIDTH=150>

<table cellpadding="4" cellspacing="1" border="0" width="100%" BGCOLOR=#1D6AA0>
<tr>
<td valign="top"><smallfont><B>
$welcometext
$home_logincode</B></smallfont><TABLE CELLPADDING=4 WIDTH=100% CELLSPACING=0 BGCOLOR="$getbgrow"><TR><TD><smallfont>$welcometext2$home_logincode2</TD></TR></TABLE></TD></TR></TABLE><P>
$buddytop
$onlineusers
$buddybottom
$loggedinusers
<table cellpadding="4" cellspacing="1" border="0" width="100%">
<tr>
<td valign="top" BGCOLOR=#1D6AA0><smallfont><B>&raquo;Email Login</B></normalfont><TABLE CELLPADDING=4 WIDTH=100% CELLSPACING=0 BGCOLOR="$getbgrow"><TR ALIGN=LEFT><TD>
<form name="login_form" action="http://plurplanet.mail.everyone.net/email/scripts/loginuser.pl" method="post" target="new"><FONT SIZE="1" FACE="Verdana,Arial,Helvetica"><B> User Name:</B></font><br><input type="text" name="loginName" size="12" value="" maxlength=32 class="bginput"></TD></TR>

<TR ALIGN=LEFT"><TD><font size="1" FACE="Verdana,Arial,Helvetica"><B> Password:</B></font><br><input type="password" name="user_pwd" size=12 maxlength=32 class="bginput"></TD></TR><TR ALIGN=LEFT><TD><input type="submit" name="login" value="Login" class="bginput"></TD></form></TR>

<TR ALIGN=LEFT><TD><FONT SIZE="2" FACE="Verdana,Arial,Helvetica"><B><a href="http://plurplanet.mail.everyone.net/email/scripts/useragreement.pl" target="new">
Sign Up Now!</B></FONT></A></TD></TR></TABLE></TD></TR></TABLE><P>



<table cellpadding="4" cellspacing="1" border="0" width="100%">
<tr>
<td valign="top" BGCOLOR=#1D6AA0><smallfont><B>&raquo;Latest Forum Topics</B></normalfont>$threadbits</td>
</tr>
</table>

</TD>
<td valign="top">

Admin
06-14-2002, 08:23 AM
Are you not using both scripts on the same domain?

Tigga
06-14-2002, 08:02 PM
No, I have the message board of my site hosted through vBulletinhosting.com and the rest of my site is hosted through a company that my father runs (so obviously I get a pretty nice discount ;)). I would just put everything on the vbulletinhosting server, but my site takes up almost 3 gb of disk space, so I'm sure that would be pretty expensive.
As I said, including the script using PHP does kind of work, but if a user is logged in it should show them the home_welcometext templates and the buddylist templates instead of the logincode. Could this possibly be some kind of a problem with the cookie's or something like that? Any idea's what I could do to make this work properly? As always, your help is greatly appreciated FireFly.

Admin
06-15-2002, 06:29 AM
The problem is with cookies, you are not surfing the "real" forums domain so cookies are not present.
Try using SSI includes... and if that fails, try an <iframe> -- it might work. :)

Tigga
06-15-2002, 07:52 AM
Thank you for the help FireFly. I figured it was some kind of a problem with cookies, but I wasn't really sure... That's why I decided to ask someone that was smarter than me. :)
I tried it with SSI, but I don't think you can use SSI to include something on a different server. I could just be doing something wrong though. If it is actually possible to use SSI to include files from another server please let me know and I'll see if I can figure out what I'm doing wrong.
I'm not very familiar with the iframe, but I'm sure I can find some sort of tutorial. I'll look that up tomorrow.
Again, thank you for the help. :)

Admin
06-15-2002, 08:11 AM
Some docs about inline frames:
http://www.w3schools.com/html/attr_iframe.asp
http://www.sbrady.com/hotsource/html/frames.html

Tigga
06-19-2002, 10:03 AM
Thank you very much once again FireFly. I think I am going to end up using the <iframe> to include the pages. Though it may not look perfect since the things from the message board tend to take a second or two longer to load, it's the only method that I can get to work, which is much better than I was doing before I got your help. :)