Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
im trying to create a simple login and register page
and i am getting these errors on my index .php
page,why is my index undefined these are the errors i am getting
Notice: Undefined index: username in C:\xampp\htdocs\mysite\forum part two\index.php on line 7
Notice: Undefined index: password in C:\xampp\htdocs\mysite\forum part two\index.php on line 8
the codes on line 7 and 8 these respectively
$username = $_SESSION['username'];
$password = $_SESSION['password'];
this is my index page
<?php
//This will start a session
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
//Check do we have username and password
if(!$username && !$password){
echo "Welcome Guest! <br> <a href=login.php>Login</a> | <a href=register.php>Register</a>";
}else{
echo "Welcome ".$username." (<a href=logout.php>Logout</a>)";
}
?>