Results 1 to 6 of 6
  1. #1
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    I am using the following code to display a page from another website within one of my pages.

    <?php
    $remote = fopen("http://www.theothersite.com/list.php", "r");
    fpassthru($remote);
    ?>

    The problem I am having is that the page on the other site has a lot of links in it, and the person who created the other site use /page2.php instead of www.theothersite.com/page2.php for their linking style.

    Therefore, once it is displayed on my site, and you click on the link, it wants to go to www.mysite.com/page2.php which won't work of course. I need to to go to THEIR site.

    Is there a workaround on my end for this?
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  2. #2
    Full Member
    Join Date
    January 18th, 2005
    Posts
    379
    I haven't ever done it myself but I think there is an html tage for this purpose. Do you have any access over the remote document ?

    You could have them enter a base tag in the head of their html
    <BASE HREF="http://www.theothersite.com/">

    Other than that you could probably get away with a str_replace like:
    str_replace("<a href=\"", "<a href=\"http://www.theothersite.com/\",$remote);

    I don't think the code will work as is because you probably need to escape out some more characters but hopefully it's a start.

  3. #3
    Affiliate Manager
    Join Date
    January 18th, 2005
    Posts
    1,056
    Give this a try:

    <pre class="ip-ubbcode-code-pre">
    &lt;?
    $path = "http://www.theothersite.com/list.php";
    $fd = fopen($path, "r");
    $file = implode( "", file( $path ) );
    fclose($fd);
    echo $file;
    ?&gt;
    </pre>

  4. #4
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    Thanks guys, but neither one worked.

    With the first suggestion I get a parse error.

    With Chet's suggestion, the links are still the same as what I started with.

    Man I do not want to use frames! I wish IFrame worked with Netscape and earlier browsers because it is the simple solution.

    Any more suggestions?
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  5. #5
    ABW Veteran Student Heyder's Avatar
    Join Date
    January 18th, 2005
    Posts
    5,482
    I don't know if it will work for what you need but this is almost too simple and it worked.
    &lt;?
    echo"&lt;base href=http://google.com&gt;";
    include 'http://google.com';
    ?&gt;

  6. #6
    Web Ho - Design B!tch ~Michelle's Avatar
    Join Date
    January 18th, 2005
    Location
    Michigan
    Posts
    2,040
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by Heyder:
    I don't know if it will work for what you need but this is almost too simple and it worked.
    &lt;?
    echo"&lt;base href=http://google.com&gt;";
    include 'http://google.com';
    ?&gt; <HR></BLOCKQUOTE>


    Hey, that almost works!

    The only problem I see now is that any link you click on goes where it is supposed to, but the page doesn't stay embedded in mine.

    If we can get around that then we will be golden.
    ~Michelle
    "All I ask is a chance to prove that money can't make me happy."
    "Work to become, not to acquire." -- Confucius

  7. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •