Results 1 to 5 of 5

Thread: Error message...

  1. #1
    Join Date
    Jul 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Error message...

    Hi,

    Due to bandwith problems i decided to make my downloads only accessible for registered members so i installed a simple user system.After i finished installing it everythings fine then they told me to add a small code to the top of every page i want protected for members only,the code was this :

    <?
    ob_start();
    include("config.php");
    if ($logged[username])
    {
    echo("You are logged in");
    }
    else
    {
    echo("You are not logged in");
    }
    ?>

    Since I wasn't sure on how to echo the downloads page i decided the use Include and did like this :

    <?php
    ob_start();
    include("http://myurl.com/config.php");
    if ($logged[username])
    {
    include("http://myurl.com/downloads.php");
    }
    else
    {
    include("http://myurl.com/login.php");
    }
    ?>

    My downloads folder is in a sub folder so I would have to unclude the whole url,idk what seems to be the problem.Is their anyway to get it to work by checking if the user is logged in and insted of echoing the page maybe continue loading it? If not logged in send them to the main login page?anyway
    thanks

    Mick

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    • You ob_start() but never ob_end_*(), so you're never going to get any output from the pages unless you further manipulated it on down the line.
    • include()ing by an absolute URL will include only the output of the file, not any variables it may define.
    • The constant "username" is never defined, insofar as I can tell (although it may be in config.php).
    Other than that, your code should be good.
    Is their anyway to get it to work by checking if the user is logged in and insted of echoing the page maybe continue loading it?
    Code:
    <?php
    require_once('config.php');
    if(!$logged[username])
      die(header('Location: http://myurl.com/login.php'));
    ?>
    Last edited by Twey; 07-08-2006 at 02:21 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hey,

    I tried that script you posted and got this error:

    Warning: main(): URL file-access is disabled in the server configuration in /home/.foobar/user/myurl.com/downloads.php on line 2

    Warning: main(http://myurl.com/config.php): failed to open stream: no suitable wrapper could be found in /home/.foobar/user/myurl.com/downloads.php on line 2

    Fatal error: main(): Failed opening required 'http://myurl.com/config.php' (include_path='.:/usr/local/lib/php') in /home/.foobar/user/myurl.com/downloads.php on line 2

    Here's the user system I'm using:
    http://techtuts.com/?view=tutorials&act=tutorial&id=8

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I said, don't use absolute URLs.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jul 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    damn,sorry didn't read it all.Now it works , Thanks for the help

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
  •