PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function membersOnly() {
if (!$_SESSION['logged']) {
$_SESSION['log_to'] = $_SERVER['REQUEST_URI'];
}
die('This page is available only to registered members,
you have to <a href="login.php">login</a> first, if ' .
"you haven't" . ' <a href="signup.php">registered</a> ' .
'yet you can do that for free.');
}
function membersOnly() {
if (!$_SESSION['logged']) {
$_SESSION['log_to'] = $_SERVER['REQUEST_URI'];
die('This page is available only to registered members,
you have to <a href="login.php">login</a> first, if ' .
"you haven't" . ' <a href="signup.php">registered</a> ' .
'yet you can do that for free.');
}
}
function membersOnly() {
if (!$_SESSION['logged']) {
$_SESSION['log_to'] = $_SERVER['REQUEST_URI'];
die('This page is available only to registered members,
you have to <a href="login.php">login</a> first, if ' .
"you haven't" . ' <a href="signup.php">registered</a> ' .
'yet you can do that for free.');
}
}
This makes a bit more sense than the frist version you've posted.
If _SESSION[logged] is set the user is allowed to visit the page, i.e. membersOnly() should redirect and stop processing the current requst if _SESSION[logged] is not set? If that is so please try
now it is redircted to message.php but the login form is not shown in it. instead it prompts: Notice: Undefined variable: file in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php on line 67
Warning: main(): Failed opening '' for inclusion (include_path='.;G:/Programs(2)/EasyPHP1-8\php\pear\') in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php on line 67
so I have to create a full page for any message I want to display?
I wanted to have one page message.php and show all messages there. then it would be like an external CSS file so easy to edit the whole site by editing one page message .php. http://pedia.sys17.net/wantprolikethis.htm
function membersOnly() {
error_reporting(E_ALL);
ini_set('display_errors', true);
if (!$_SESSION['logged']) {
$_SESSION['log_to'] = $_SERVER['REQUEST_URI'];
session_write_close();
$file="login.php";
include "http://127.0.0.1/ha/previous/New%20Folder/htdocs/message.php";
die();
}
still getting the error:
Notice: Undefined variable: file in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php on line 67
Warning: main(): Failed opening '' for inclusion (include_path='.;G:/Programs(2)/EasyPHP1-8\php\pear\') in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php on line 67
it shows the login form now. but it prompts another error upon login:
Fatal error: Call to a member function on a non-object in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\login.php on line 36
this error does not occur when I use login.php alone for logging in.
line 36 begins as: