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

Attempt to assign property of non-object in...
I'm having issues with the following function in PHP 5...

function getTreeWithChildre

Need help with simple code, back and forward buttons.
Basically, I have a set of pages in a folder, which have the title somephrasehere_09.php, somephrase

preg_replace question
Hello!!

I hope someone can help me with preg_replace.

I load two tables from an extern

SAP Treasury - Commodities
We are running SAP ECC 6.0 with Treasury Activated.
EA-FIN is also activated (SFW5).

Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w

setcookie and isset($_COOKIE(name)) seem very finnicky.
I'm currently playing around with a user system with login and registration. I'm trying to use cooki

Rand() help needed
Hi all,

Can someone explain and give me a quick example of how I would go about this?

removing space from the end of a variable
i have a variable $image which contains the following url "http://tiles.xbox.com/tiles/oo/P5/0m

Create multiple (n) arrays
Hi there,

I have the following need:

I have 2 arrays (coming from a databases)

Need help with unexpected T-STRING error
I'm a newbie and I'm still learning PHP. However this error has me stumped. I've googled, searched t

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