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

Did you know?Explore Trending and Topic pages for more stories like this.
session_start();

if($_SESSION['username']) //line5
echo "Welcome, ".$_SESSION['username']."!<br /><a href='logout.php'>Logout.</a>";
else
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 Include not working
The website is http://www.grlistingservices.com

The code block is as follows:

<

Upload file and add HTML
Hey everyone,

I have a client has meeting agendas and minutes that should be posted online. I

elseif help!
OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and

$_GET problem
Hi all,

Have a bit of a problem with a little piece of code, I am not sure if this should be

Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010

Blocking video streaming
Hello everyone,

I post a message here because i didn't find any solution yet.
I just finis

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<

Save username into DB
OkaY so I got my blog to actually save the posts and whatever, all I need now is for it to keep the

void* and sizeof()
Hi,

Using void* and sizeof is it possible to get the value of the object ?

I understan

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