SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I have this code:

    Code:
    <html>
    <head>
    <title>Print</title>
    </head>
    <body bgcolor="#ffffff" text="#000000" id=all>
    <?
    $url = 'http://www.webdevelopershq.com/articles/article_1.shtml';
    
    $lines_array = file($url);
    
    $lines_string = implode('', $lines_array);
    
    eregi("<!-- content -->(.*)<!-- /content -->", $lines_string, $head);
    
    echo $head[0];
    ?>
    </body>
    </html>
    Where it has $url = 'http://www.webdevelopershq.com/articles/article_1.shtml';

    How can I get it to insert the address of the refering page automaticly?

    Thanks,
    Justin Sampson

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use phpinfo() method for getting some environment variables.
    I believe they has some for that, but don't have time to check for details. Sorry!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $url = getenv( 'HTTP_REFERER' );

    That should do the job for you.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  4. #4
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Karl, Thats what I thought I would have to do but I can't get it to work. Check out http://www.webdevelopershq.com/articles/article2.shtml and then go to http://www.webdevelopershq.com/print.php I just get this error:

    Warning: file("") - No such file or directory in /home/webdevel/public_html/print.php on line 9

    Warning: Bad arguments to implode() in /home/webdevel/public_html/print.php on line 11

    I thought that I would have to use HTTP_REFERER but no matter how I typed it in the code it doesn't insert an address?

    Is this right so far?
    Code:
    <?
    $url = getenv( 'HTTP_REFERER' );
    
    $lines_array = file($url);
    
    $lines_string = implode('', $lines_array);
    
    eregi("<!-- content -->(.*)<!-- /content -->", $lines_string, $head);
    
    echo $head[0];
    ?>
    It works fine if I just type in the full address but if I did that I would need a copy of that code for every article on my site!

    Thanks,
    Justin Sampson


Bookmarks

Posting Permissions

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