Help in redirecting my php page

I trying to redirect to the same page.But the table not show up…redirecting to another is not an option.i want to validate to the data on the same page.
here is my code.
Thanks for your help.


<?php
session_start();
include_once("conn.php");
if(isset( $_SESSION['username']));

$_SESSION['name']=$_GET['UserName'];
$uname=$_SESSION['name'];
$query=mssql_query("Select * FROM tblUser where UserName='$uname' ");
$d=mssql_query("Select DeptName from tblDept");
$user=mssql_query("Select * from tblUserLevel");

?>
<html>
<head>
	<title>Edit User</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen,projection" />
</head>
<body>
<center>
<fieldset class="userlevel">
<legend>Edit Profile</legend>
<?php
if(isset($_POST['save'])){
$editerror="";
$error=0;
	if(!$_POST['fname']){
		$editerror=$editerror."First Name";
		$error=$error+1;}
	if(!$_POST['lname']){
		$editerror=$editerror."Last Name";
		$error=$error+1;} 	
	if(!$_POST['email']){
		$editerror=$editerror."Email Address";
		$error=$error+1;}
	if(!$_POST['dept']){
		$editerror=$editerror."Department";
		$error=$error+1;}
	if(!$_POST['userlevel']){
		$editerror=$editerror."Last Name";
		$error=$error+1;}
	
	if($editerror!="")
		echo "Fill out the following fields:<br><font size='3' color='#FF0000'>$editerror</font>";

	if($error==0){
	update($_POST['uname'],$_POST['fname'],$_POST['lname'],$_POST['email'],$_POST['dept'],$_POST['userlevel'],$con);
	echo "<script>alert('User has been Edit.')</script>";
	header('location:Supportviewuser.php');
	}
}
function update($uname,$fname,$lname,$email,$dept,$userlevel,$con){
	 mssql_query("Update tblUser Set Firstname='$fname', Lastname='$lname',Email='$email',Dept='$dept',UserLevel='$userlevel' where UserName='$uname' ");
	mssql_close($con);
}

	while ($row=mssql_fetch_array($query)) {
			$id=$row['id'];
	
?>
<table>
<form method='post' action='edituser.php' onSubmit="javascript: var x=window.confirm('Do you wan\\'t to save this User?');if (!x) return(false);">
<tr>
	<input type='hidden' value=<?php echo $row['UserName'] ?> name='uname'>
	<td>User Name:</td>	
	<td><label for='uname'><?php echo $row['UserName']?></label> </td>
</tr>
<tr>
	<td>First Name:</td>
	<td><input type='text' value=<?php echo $row['Firstname']?> name='fname'></td>
</tr>
<tr>
	<td>Last Name:</td>
	<td><input type='text' value=<?php echo $row['Lastname'] ?> name='lname'></td>
</tr>	
<tr>
	<td>Email Address:</td>
	<td><input type='text' value=<?php echo $row['Email'] ?> name='email' size='35'></td>
</tr>
<tr>
	<td> Department : </td>
	<td>
	<?php 
		echo "<select name='dept' tabindex='8'>";
		echo "<option selected>".$row['Dept']."</option>";
		while($dept=mssql_fetch_array($d)){
		echo "<option>".$dept['DeptName']."</option>";
		}echo '</select>';
	?>
	</td>
</tr>
<tr>
	<td>User Level:</td>
	<td>
	<?php 
		echo "<select name='userlevel' tabindex='9'>";
		echo "<option selected>".$row['UserLevel']."</option>";
		while($userlvl=mssql_fetch_array($user)){
		echo "<option>".$userlvl['UserLevel']."</option>";
		}echo '</select>';
	?>
	</td>
</tr>
<tr>
	<td><input type='submit' value='Save' name='save'></td>
</tr>
</form>
</table>
<?php
}
?>
</fieldset>
</center>
</body>
</html>

what is the error you got, when you run the code?
Are you using mysql database?

Thanks for the reply i am using mssql but its pretty much the same…
there is no error, but i’m just wondering how to display the same page after the validation…
the first: is the validation if there is a empty texbox.
the second: print/echo the empty field…

the problem is i cant view the table where i must input the data…

Can anyone help me with this…
Thanks…