Undefined index: username HELP NEWBIE

Posted on 16th Feb 2014 07:03 pm by admin

I am trying a simple login/logout for my website. It works well with checking if the username exists in the database to logging in. I used $_SESSION['username']=$myusername; However, when I log-out, then I go to a page with this code

Code: <?php


if($_SESSION['username']) //line5
echo "Welcome, ".$_SESSION['username']."!<br /><a href='logout.php'>Logout.</a>";
die ("You must be logged in!");


It gives me an error. It says Notice: Undefined index: username in C:wampwwwdatbasmember.php on line 5

I just want to know how to fix this. Thank you

No comments posted yet

Your Answer:

Login to answer
233 Like 43 Dislike
Previous forums Next forums
Other forums

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

Removing Title From database problem
Hi again ! i am having an issue with updating database. When i update any price of a title it remove

Using the $_GET variable to view certain records

First let me explain my problem, I have 2 pages the first page pull a list of Guide ti

Impact of movement type 412 E on MAP

Usage of movement type 412 E is causing huge change in MAP .

Is there any r

How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.
I'll create a table called "Use

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash