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

Create a form of 2 numbers input and find the greatest.
Hi, everybody.

I have a homework in my training of php, which ask you to make a form that ask

foreach and array need help combining
Hi guys.

Here's the code

Code: array(
'tag' => 'code',<

this code is strange !
Hi i got this code from the web.. It checks for live and dead socks
It is working perfectly on my

Sending UDP Raw socket
I truly need help on this. I am trying to write a test program that simulate a network environment

FROM_UNIXTIME($phpdate);
Hello,

I tried to use this :

$date = FROM_UNIXTIME($phpdate);

ANd I was t

Help to integrate whois Domain Details to website
Hi,

can i know is their any php script r methods to add domain details to my website.

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

newbie error
what is wrong with this code ?

<html>
<body>

<?

order by date not ID number help php
I am trying to orginize the following code to order by date not id number.
any help would be grea

ereg_replace issue
hi there people

i have this code happening with regards to my wamp server. is this something

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