I am getting this problem whenever I login from index.php to admin_area.php. I am giving the codes of the two files. Please help.

Index.php

<?php
	session_start();
	include("../lib/globals.php");
	
	
	
	if(isset($_REQUEST['submit']))
	{
		$u_name=$_REQUEST['username'];
		$pass=$_REQUEST['password'];
		$sql="select * from `user_table_master` where `user_name`='$u_name' and `password`='$pass'";
		
		$result=mysql_query($sql);
		$row=mysql_fetch_array($result);
		
		$num_of_rows=mysql_num_rows($result);
	
		if($num_of_rows>0)
		{
			$_SESSION['logged_in']='y';
			$_SESSION['user_type']=$row['user_type'];
			$_SESSION['user_formation']=$row['formation'];
			$_SESSION['user_name']=$row['user_name'];
			$_SESSION['name']=$row['name'];
			$_SESSION['user_id']=$row['user_id'];
			$_SESSION['can_see_remarks']=$row['can_see_remarks'];
?>
		<script language="JavaScript">
			document.location.href='admin_area.php';
		</script>
<?php	
		}	
		else
		{		
?>
			<script language='javascript'>
					alert("Either 'UserName' or 'PassWord' is incorrect");
			</script>	
<?php
		}	
   	}
		
?>
			
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SMERians' Corner</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../style/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function validate()
{
	var username=document.f1.username.value;
	var password=document.f1.password.value;
	if(username=="")
	{
		alert('Please enter Login Id.');
		document.f1.username.focus();
		return false;
	}
	if(password=="")
	{
		alert('Please enter Password.');
		document.f1.password.focus();
		return false;
	}
}
</script>
</head>

<body leftmargin="0" topmargin="0" alink="#000000" vlink="#000000" link="#000000">
<table width='100%' height="117" border='0' cellspacing="0">
<tr height="60">
<td align="center" bgcolor="#2A166F" class="sty1">
  <table id="Table_01" width="567" height="90" border="0" cellpadding="0" cellspacing="0">
	<tr bgcolor="00AEEF">
	    <td width="530" align="center" valign="middle" bgcolor="#2A166F"> <font size="+5"><img src="../images/ADMIN1.gif"></font></td>
	</tr>
</table>
</td>
</tr>
<tr height="2px"><td bgcolor="#FFFFFF"></td></tr>
<tr height="4px"><td align="right" bgcolor="00aeef"></td></tr>
</table>
<form name="f1" method="post" action="index.php" onSubmit="return validate();">
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="36%" border="0" align="center" cellspacing="0" cellpadding="0" class="tab_sty1" bgcolor="00AEEF">
	<tr bgcolor="#000000" height="20"><td colspan="4" class="mysty1"><div align="center"><font color="#FFFFFF"><b>SMERians' Login</b></font></div></td></tr>
	<tr><td><div align="center"></div></td>
	  <td>&nbsp;</td>
	  <td>&nbsp;</td>
	  <td width="45%" rowspan="6"><img src="../images/key.jpg" width="150" height="112"></td>
	</tr>
	<tr><td>&nbsp;</td>
	  <td>&nbsp;</td>
	  <td>&nbsp;</td>
    </tr>
    <tr>
		<td width="27%" align="center" class="mysty2"><div align="right">&nbsp;Login ID : </div></td>
		<td width="2%">&nbsp;</td>
		<td width="26%" align="left"><input name="username" type="text" id="username" size="15" maxlength="20"></td>
	</tr>
	<tr>
		<td align="center" class="mysty2"><div align="right">Password : </div></td>
		<td>&nbsp;</td>
		<td align="center"><div align="left"><input name="password" type="password" id="password" size="15"></div></td>
	</tr>
	<tr><td align="center">&nbsp;</td>
	  <td align="center">&nbsp;</td>
	  <td align="center">&nbsp;</td>
    </tr>
	<tr><td align="center">&nbsp;</td>
	  <td align="center">&nbsp;</td>
	  <td align="center">&nbsp;</td>
    </tr>
	<tr><td align="center" colspan="4"><input type="submit" name="submit" value="Submit" ></td></tr>
	<tr><td colspan="4">&nbsp;</td></tr>
</table>
</form>
</body>
</html>

admin_area.php

<?php   
   session_start();
	if(!empty($_SESSION['logged_in']))
	{
	   $user_name=$_SESSION['user_name'];
	   $user_type=$_SESSION['user_type'];
?>
<html>
<head>
<title>SMERians' Corner</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../style/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function validate()
{
	var username=document.f1.username.value;
	var password=document.f1.password.value;
	if(username=="")
	{
		alert('Please enter Login Id.');
		document.f1.username.focus();
		return false;
	}
	if(password=="")
	{
		alert('Please enter Password.');
		document.f1.password.focus();
		return false;
	}
}
</script>
<style type="text/css">
<!--
.style12 {font-size: 16px}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" alink="#000000" vlink="#000000" link="#000000" onLoad="startclock()">
<?php include("admin_header.php");?>
<table width='98%' border='0' cellspacing="0">		
<tr>
<td width="190" align="left" valign="top"><?php include("admin_left.php"); ?></td>
<td align="center" valign="top">
<table width="800" border="0" align="center">
<tr><td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"><? echo date('d-m-Y'); ?>&nbsp;&nbsp;<span id="showDate"></span></font></td></tr>
</table>
<br><br><br>
<table width="500" border="0" align="center">
  <tr>
    <td class="text4">
	<div align="center">
	   <?php if (isset($_GET['val']))
	   		{
	   ?>
	   <font size="+2">You Are Not An Authorised User To See This Page</font>
	   <?php
	        }
			else
			{
		?>
		<font color="00aeef" size="+2">
		Welcome <?php echo"'".$_SESSION['name']."'"; ?></font>
		<?php	
			}
	   ?>
	   </div>
	</td>
  </tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
	}
	else
	{
		header("location:index.php");
	}
?>

Please help me as soon as possible

Make sure there are no characters in the file before the <?php and save any UTF-8 files without the BOM.

Be sure that session_start(); is the first line in each of your codes without spaces or blank lines.

<?php
session_start();
............................
?>

Be sure that session_start(); is the first line in each of your codes without spaces or blank lines.

<?php
session_start();
............................
?>

Thank You Very Much. There was a space before the <?php tag.

It solved my problem. Thanks

Dear friend

Can you please remove the session_start(), because they already start the seecion in include("../lib/globals.php"); file , these reason only show this error

THanks

This article has been dead for over six months. Start a new discussion instead.