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

'grab_files', multiple extension?
hey guys,

can anyone suggest a way to make to following line of code look for files with more

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai

Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d

Error when call dll from oracle
Hi all, please help me!

I have dll write C language, I want call it from oracle procedur

Recording popularity by day, week.. all time?
Hey everyone, I'm creating a site designed around users uploading music. How can I implement a syste

Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els

remove innitial

and

tags
i am using tiny_mce as a text editor for my CMS.
buy now the problem is it add <p>

PL/SQL: ORA-00947: not enough values error message
Hi all i am getting Error(25,63): PL/SQL: ORA-00947: not enough values error message when executing

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

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