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

Multi Dimensional Array Append
Hi Guys

I have a function that returns a multidimentional array eg

$result = functio

Add code to enable passing of checkbox variable on login
Ok, I have a login page, but want to add a checkbox that when checked and successful login is made i

EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules t

Problem with array max size.
Hi to everyone,
I've got a homework about filling a bidimensional array un spiral shape, I alre

php/xmlrpc class issue
I am working on xml-rpc in php to start with.

I have a class that only has variables defined

Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the

Opening Multiple Files/Links in Order.
I want to open links in order/one-by-one and check each for a specific string.

Example:
I

classic dynpro : hide area and auto adjust hights
Hi,

I want to develop a similar user interface as is used in standard transaction MIGO.

How do I replace any number of character occurences with one occurrence?
How do I replace any number of character occurences with one occurrence?

Let's say I have:

ALV List display - header width adjust
Hi,

I am using REUSE_ALV_LIST_DISPLAY for my ALV display.The width of the ALV varies for

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