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

pageination not working right... coping images over 4 pages
Code: <?php //This code will obtain the required page number from the $_GET array. Note that

PHP switch function help
Hi, I am trying to create a search function for a directory website. On the search function on html

Extracting Long text from message class with parameters
Hi,

I would like to extract the long text from a message class. However, the long text ha

INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, suc

image upload, resize THEN submit form
Ok so I have a form that requires the user to upload an image, and then do something with that image

Date/Time and Checkbox
Hi Everyone,

I am trying to figure out how to insert the current date and tim

Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree

To add a field on the screen XK02.
Hi All,

How to add an additional field in the vendor change control screen XK02.
The

sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

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