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

PHP time (deadline within one week)
I have a column ['projdue'], which stores the deadline for a project.
I have PHP code and <

PHP - MySQL Fail
My PHP code will only execute the first part of my code...

Code: <?php

sessio

Trouble checking SESSION cookie
I am trying to use $_SESSION cookies to verify admin privileges .
I don't understand why this is

.htpasswd Registration Form
Hi,
I wanted to make an htpasswd registration form.
I found this code on the internet but have

Placing and array within an array then sorting it!
I have a page that runs two large mysql queries and saves the results into arrays, in php I then per

Xacute search within SQL results
I have a query that is pulling data, and I want to return a specific value from the results of that

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message

php unable to sent email
Hi, guys, I try to send a email through php but unfortunately the mail unable to sent. Here is my co

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