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

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

Windows 7
Windows 7 default user account control worries experts. Corporate IT departments should be pleased w

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

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

Dynamic memory problem
Hey,

At the beginning of my code, I have this line:

Shape* gShape = 0;

CODE NOT WORKING
Code: [Select]<?php
//include shared codes

include '../lib/common.php';
include

Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is

Encrypt php code?
Is it possible to encrypt php code in files,
so that it displays a load of unreadable characters

Shopping Cart
Can anyone direct me to a Simple, Basic structure of a shopping cart.
New to classes. I want to s

BB_Code error
I'm having a problem with a custom built function and keep getting this error:


Warning: M

How can I Compare two xml documents?
Hi all,

I am doing a POC for my project and I am using XE database 10g version.

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