472,958 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 3234
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: harris | last post by:
I am needing some help with a few asp pages and a login script. Let me start by describing my project. I am trying to connect to a database and verify a users login and password, then based on...
6
by: David Lozzi | last post by:
Howdy, I'm new to classes. Below is my class User. (is this a reserved namespace or class?) It works great, kind of. If I specify the username and password, the correct firstname and lastname...
2
by: dalsoth | last post by:
Hi Guys I have created a website and to makes things easier i decided to use dreamweaver to do the secure login section and access levels for the pages. When testing locally on wamp my website...
25
by: crescent_au | last post by:
Hi all, I've written a login/logout code. It does what it's supposed to do but the problem is when I logout and press browser's back button (in Firefox), I get to the last login page. In IE,...
3
abdoelmasry
by: abdoelmasry | last post by:
Hi Friends i need help in sessions im passing variables between pages using sessions this is the main page thats mean the home page the main page have table to show messages for users , it have...
2
by: Gordon Burditt | last post by:
I had this idea about preventing session fixation, and I'm wondering what anyone else thinks about it. The idea is, essentially, don't allow session ids that YOUR PHP didn't generate (and aren't...
8
by: sathyashrayan | last post by:
Dear group, For a log-in page I have created a mysql db and user registers with a user name and password. The password field is encrypted with $passwd = sha1($_REQUEST); I insert the...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
4
by: craigtomo | last post by:
I am getting the following error when i try to log on to my data base Warning: session_register() : Cannot send session cookie - headers already sent by (output started at...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.