Log in

View Full Version : Error message...



confusio
07-08-2006, 02:07 AM
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

Twey
07-08-2006, 02:16 AM
You ob_start (http://www.php.net/ob-start)() but never ob_end_* (http://www.php.net/manual/en/ref.outcontrol.php)(), so you're never going to get any output from the pages unless you further manipulated it on down the line. include (http://www.php.net/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?
<?php
require_once('config.php');
if(!$logged[username])
die(header('Location: http://myurl.com/login.php'));
?>

confusio
07-08-2006, 02:45 AM
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

Twey
07-08-2006, 02:51 AM
I said, don't use absolute URLs.

confusio
07-08-2006, 03:19 AM
damn,sorry didn't read it all.Now it works , Thanks for the help ;)