Code login & logout proplem

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

index.php

<html>
<head><title>Home</title>
<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;
element.style.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] = "http://www.principlesofaccounting.com"
newplace[1] = "http://www.silcom.com/~bevjack/"
newplace[2] = "http://www.online-bachelors-degrees-online.com"

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

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

</script>
</head>

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

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

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

<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 AccountingCoach.com.

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, AccountingCoach.com 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.

</p>


</div>

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

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

</div>

</body>
</html>

login.php

<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];
if($username&&$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.";

	 $_SESSION['username']=$username;
      }
      else
          echo "Incorrect password!";

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


logout.php

<?php

session_start();

session_destroy();

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

member.php

<?php

session_start();

if ($_SESSION['username'])

	echo "Welcome, ".$_SESSION['username']."! <br/><a href='logout.php'</a>Logout";
else
	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.