468,458 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

HELP W/ PHP Session Login App

Hi Guys,
Please HELP! I'm new to PHP and would like to get your professional
help!
I"m writing simple and small login app using php session variable. I
have 3 php scripts. The first is just a simple php form, login.php,
that passes the variables to auth.php.
Auth.php just validates that the username and password is correct. If
they match, i will set the php session,
$_SESSION['logon'] = "ok", then redirect the user to anothor page,
ADMIN.PHP

ADMIN.PHP:
<?
session_start();
if ($_SESSION['login'] != "ok")
header("Location: login.php");
else
/* do some stuff 8/
?>

My code works well on the login.php and auth.php. But for some reason,
when I get to ADMIN.PHP, it says that they it has an "UNDEFINED INDEX,
LOGIN".
Can anyone help me or have a sample php program that uses sessions for
login?
Much Help would be appreciated.
Thanks in advance,
PHP NOOBIE

Jul 17 '05 #1
3 3085
On 2005-01-27, ne******@gmail.com <ne******@gmail.com> wrote:
Please HELP! I'm new to PHP and would like to get your professional
If you give us professional pay :p

Auth.php just validates that the username and password is correct. If
$_SESSION['logon'] = "ok", then redirect the user to anothor page,
j> ADMIN.PHP: if ($_SESSION['login'] != "ok")


Notice that login != logon.

But before you check the value in the 'login'/'logon' key of the array,
you might want to use http://www.php.net/array_key_exists to make sure
there is such a key (and value).

if (!array_key_exists('logon', $_SESSION) || $_SESSION['logon'] != 'ok')
{
// don't know how well browsers support redirection with a relative
// uri - http://www.ietf.org/rfc/rfc3986.txt
header("Location: login.php");
}

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2
Better if u can improve ur login script.
problem is if the connected user keep the browser after logout without
closing we can go to the other pages from ur auth.php. bec IE will
supply the supplied passwo and username. use some query string in auth
page relating with session ID and check it in the auth page. and after
logout regenerate new session id. so if another user back, he can`t
relate new sessionid with previous query string.

Jul 17 '05 #3
In article <11**********************@c13g2000cwb.googlegroups .com>,
ne******@gmail.com says...
Hi Guys,
Please HELP! I'm new to PHP and would like to get your professional
help!
I"m writing simple and small login app using php session variable. I
have 3 php scripts. The first is just a simple php form, login.php,
that passes the variables to auth.php.
Auth.php just validates that the username and password is correct. If
they match, i will set the php session,
$_SESSION['logon'] = "ok", then redirect the user to anothor page,
ADMIN.PHP

ADMIN.PHP:
<?
session_start();
if ($_SESSION['login'] != "ok")
header("Location: login.php");
else
/* do some stuff 8/
?>

My code works well on the login.php and auth.php. But for some reason,
when I get to ADMIN.PHP, it says that they it has an "UNDEFINED INDEX,
LOGIN".
Can anyone help me or have a sample php program that uses sessions for
login?
Much Help would be appreciated.
Thanks in advance,
PHP NOOBIE


I have a compact login package available a
http://www.treenetnz.com/packages/login.tar.gz
(I can zip it if you need that, RAR can read as-is).

At present it uses MySQL to produce the first auth and stores its state
in _SESSION.

Modify it if you want.

--
AJ
Treehouse Networks abuse@
www.treenetnz.com
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by harris | last post: by
6 posts views Thread by David Lozzi | last post: by
25 posts views Thread by crescent_au | last post: by
2 posts views Thread by Gordon Burditt | last post: by
8 posts views Thread by sathyashrayan | last post: by
1 post views Thread by =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post: by
4 posts views Thread by craigtomo | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.