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

Re-Order by ID Number
I have a cms set up for inputting an image, thumb, title, pdf, and eps. When input the database ass

limitations on array_unique()
Does any one know what/how imitations are applied to array_unique? I have an issue where no matter h

multiple recipients + dbuser mail recall
Hello,

I am building a php login script.

When the user registers the script will send

C problem struct and string
Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.<

Open link with largest int string first
I have the following links i would like to open either all at once or one-by-one. How would i procee

Storing the referrer in session... problems with tabs
Hello All

I am currently working on an ERP project based on the MVC methodology, when a user

with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s

List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab

need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user s

I need help with formatting date from mysql! with php!
Hello guys

*Note: this is a php question not MySQL question, please do not move it to mysql s

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