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

moving mouse to display image coordinates
I have an existing MFC application that shows an image in the main window.
I'd like to be able to

1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.


In some case, there will be 100+ of the

Dynamic links in an include file
I am working on a small piece of code that counts records from a database and displays the result to

How can I uploading Transactional Data from Legacy to New SAP system
Hell Gurus,

I am overwhelmed with questions on how to migrate huge volume of Sales Orders

Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem

IS Retail & Manufacturing
Hi

Can IS Retail and Manufacturing activities be done in same instance ie. in same client

Will an XHTML DOCTYPE interfere with my PHP if I'm not experienced enough?
I've read this article here: http://friendlybit.com/html/why-xhtml-is-a-bad-idea/

In a nutshe

Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..

I need to pull data for clien

how to validate date using javascript
I need to validate date in textbox using javascript..
The date is must be not greater than TODAY

Multidimensional $_POST
Hello

How to get a single array from array of array (2 - dimension).
For example I have a

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