Code login & logout proplem

I write this program after do login or logut go to other page
I need to remain index page


<link rel="stylesheet" type="text/css" href="CSS/style.css" />
<meta name=" Keywords" content="accounting,princple,credit,debit.income,balance,capital,liabilities"/>

<script type="text/javascript">
function changeColor(id, color) {
element = document.getElementById(id);
event.cancelBubble = true;
oldColor = element.currentStyle.background; = color;

if (document.images) {
ads = new Array(3);
ads[0] = "images/shade.jpg";
ads[1] = "images/girllabtop.jpg";
ads[2] = "images/internetmerchantaccounts.jpg";

newplace = new Array(3);
newplace[0] = ""
newplace[1] = ""
newplace[2] = ""

var timer = null
var	 counter = 0
function banner() {
	    timer=setTimeout("banner()", 4000);
		if (counter >= 3)
		counter = 0;
		document.bannerad.src = ads[counter];

function gothere() {
		counter2 = counter;
		window.location.href = newplace[counter2];


<body onload="banner()" >

<!-- Header !-->
<div id="header"><img src="images/logoaccounting.jpg" width="100%" height="100%"/></div>

<!-- left Content !-->
<div id="leftContent" > <br/>

<form action='login.php' method='POST'>
<p>User Name:<br /> <input type='text' name='username'><br/>
Password: <br /><input type='password' name='password'><br/><input type='submit' value='Login'></p></form>

<div class="linkdiv" id="div1" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"  > <br/><a  href="index.php" style="color:white">Home</a></div>
<div class="linkdiv" id="div2" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"   > <br/><a href="material.html" style="color:white">Material</a></div>
<div class="linkdiv" id="div3" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"  > <br/><a href="contactUs.html" style="color:white">Contact us</a></div>
<div class="linkdiv" id="div4" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"   > <br/><a href="video.html"style="color:white">Video</a></div>
<div class="linkdiv" id="div5" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"   > <br/><a href="test.html"style="color:white">Online test</a></div>
<div class="linkdiv" id="div6" onMouseOver="changeColor(, '#CCFB5D');" onMouseOut="changeColor(, '#3090C7');"   > <br/><a href='register.php' style="color:white">Register</a></div>

<div class="center"><a href=""><img src="images/facebook_180.gif" alt="facebook"/></a></div>
<div class="center"><a href=""><img src="images/twitter_180.gif" alt="twitter"/></a></div>

<!-- Main Content !-->
<div id="mainContent">
<marquee scrolldelay="5"  scrollamount="4" width="700">The midterm exam will be on 10/31/2010</marquee>

<img src="images/plant.bmp" alt="growth" style="float:left;margin-right:.5em"/>
<h2 ><em class="myfont">No road is too long for him who advances slowly and does not hurry, and no attainment is beyond his reach who equips himself with patience to achieve it.
<br /><span style="float:right" > Jean de La Bruyere</span> </em></h2>
<br />
<p>This explanation of accounting basics will introduce you to some basic accounting principles, accounting concepts, and accounting terminology. Once you become familiar with some of these terms and concepts,
you will feel comfortable navigating through the explanations, drills, puzzles, and other features of

Some of the basic accounting terms that you will learn include revenues, expenses, assets, liabilities, income statement, balance sheet, and statement of cash flows.
You will become familiar with accounting debits and credits as we show you how to record transactions. You will also see why two basic accounting principles,
the revenue recognition principle and the matching principle, assure that a company's income statement reports a company's profitability.<br/>In this explanation of accounting basics,
and throughout the entire website, will often omit some accounting details and complexities in order to present clear and concise explanations.
This means that you should always seek professional advice for your specific circumstances.



<!-- Right Content !-->
<div id="rightContent">

<a href="javascript:gothere()" class="center"><img src="girllabtop.jpg" width="200" height="200" BORDER="0" name="bannerad"></a>
<img src="images/IconDemon---ID.png"/>
<img src="images/inverse-logic---IL.jpg"/>
<!-- Footer !-->
<div id="footer" > <br/><br/><b>King Abdul Aziz University- CPIS 358 - &copy Copyright 2010 All Rights Reserved</b>






$username = $_POST['username'];
$password = $_POST['password'];

$connect = mysql_connect("localhost","root","") or die ("couldn’t connect!");
mysql_select_db("phplogin") or die ("couldn’t find db");

$query = mysql_query("SELECT * FROM user WHERE username ='$username'");

$numrows = mysql_num_rows($query);

if ($numrows !=0)
//code to login

while ($row = mysql_fetch_array($query))
// to get value enter by user
	$dbusername = $row['username'];
	$dbpassword = $row['password'];

//check to see if they match!
   if ($username==$dbusername&&md5($password)==$dbpassword)
	 echo "You’re in!<a href='member.php'> click</a> here to enter the member page.";

          echo "Incorrect password!";

  die ("That user doesn’t exist");
	die("Please enter and username and apassword");





	echo "You’ve been logged out. <a href='index.php'>Click here</a> to return.";




if ($_SESSION['username'])

	echo "Welcome, ".$_SESSION['username']."! <br/><a href='logout.php'</a>Logout";
	die ("you must be logged in!");

The first thing you should do in login.php is sanitise the user inputs using [fphp]mysql_real_escape_string[/fphp] or you could use prepared statements instead. But you really should sanitise your user inputs because your code is vulnerable to sql injection.

Then to redirect back to your index page after the user has been logged in, change the href in your link in login.php to point to your index.php. At the top of index.php you will need to start a session and check if the session variable that you set in login.php exists or not and then display the appropriate content for being or not being logged in. I would recommend you use another session variable besides the username as your session variable for determining if a user is logged in or not. Since you said you wrote all that code, modifying it should be fairly straight forward for you.