Posted: Mon Jan 23, 2006 11:33 pm
As long as it's educational. I just want to make sure anyone who views this topic gets all the sides.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
session_start();
if (empty($_POST['user']) || empty($_POST['pass']))
die('GO AWAY');
if ($_POST['user'] == 'test_user' && $_POST['pass'] == 'test_pass')
{
$_SESSION['log'] = true;
echo '<meta http-equiv="refresh" content="0;url=secure_page.php">';
}
else
die('GO AWAY');Code: Select all
session_destroy();Put session_start() at the top of any pages you want to detect that they are logged in on.nickman013 wrote:how can i keep them logged in if they go to a unprotected page?
nickman013 wrote:how can i keep them logged in if they go to a unprotected page?
Code: Select all
session_start();
if (empty($_POST['user']) || empty($_POST['pass']))
die('GO AWAY');
if ($_POST['user'] == 'test_user' && $_POST['pass'] == 'test_pass')
{
$_SESSION['log'] = true;
echo '<meta http-equiv="refresh" content="0;url=secure_page.php">';
}
else
die('GO AWAY');anybody?nickman013 wrote:1. How would i add users to this?
yeah thats true, i just need to know thee 3 things.
would it be elseif?Code: Select all
session_start(); if (empty($_POST['user']) || empty($_POST['pass'])) die('GO AWAY'); if ($_POST['user'] == 'test_user' && $_POST['pass'] == 'test_pass') { $_SESSION['log'] = true; echo '<meta http-equiv="refresh" content="0;url=secure_page.php">'; } else die('GO AWAY');
2. to logout, can i just addto login.php and the logout link would be,Code: Select all
session_destroy();
<a href=login.php>logout</a>?
3. how can i keep them logged in if they go to a unprotected page?