PHP / SQL code help

Permabanned
Joined
30 Oct 2005
Posts
64
Location
Stoke On Trent
A friend at uni is having problems with her final year project, in the code below it is falling over when it gets to lines 69, 60, 55, 52 and 8.

The error says that header has already been defined on line 5 (which is where the first echo is.....

please help.:(

Code:
<?php
// allows session info to be used on this page
	session_start();
	session_name("user");
	echo "1st point";
	// if this script isn't receiving form data, exit fast
/*	if(!isset($_POST['btnlogin']))
	{ header("Location:Loginpage.php");
		session_write_close();
		exit();
	}
*/
	echo "2nd point";
$txtUsername = $_POST['txtUsername'];
$Password = $_POST['txtPassword'];
echo "3rd point";
	if( ( !$txtUsername ) or ( !$Password ) )
		{ header( "Location:Loginpage.php" ); exit(); }
		echo "4th point";
	// creates a new Common-Object-Model (COM) connection object
	$adoCon = new COM("ADODB.Connection");
	
	$thisfolder = dirname(__FILE__);
	
	// opens the connection using a standard Access connection string
		$adoCon->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$thisfolder/scheduler.mdb");
	echo "5th point";
	//Create sql query
	$SQL="SELECT Epassword FROM Login WHERE Eusername = '$txtUsername'";
	
	// execute query
	try
	{
		$rs = $adoCon->Execute($SQL);
	}
	catch(Exception $e)
	{
		die( "Could not execute query" );
	}
	
	//if there is a match the log-in is authenticated
	if(!$rs->EOF )
	{
		if($Password == $rs->Fields('Epassword')->Value)
		{
		 $msg = "Welcome $txtUsername.";
		 
		//set cookie
		setcookie('btnlogin','$txtUsername');
	 	}
		else 
		{ header( "Location:Loginpage.php" ); exit(); }
	}
	else
	{ header( "Location:Loginpage.php" ); exit(); }
	
	echo "6th point";
	{	// if logged on okay, remembers user's name as session variable
		$_SESSION['user'] = '$txtUsername';
		header("Location:scheduler.php");
		session_write_close();
		exit();
	}
	echo "7th point";
// closes the connection, frees up resources
	$adoCon->Close();
		$adoCon = null;
		
	header("Location: Loginpage.php");
	session_write_close();
echo "8th point";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	background-color: #FFFFCC;
}
.style1 {font-size: xx-large}
-->
</style></head>

<body>
<table width="100%" height="130%"  border="1" bgcolor="#FFFF99">
  <tr>
    <td height="128" colspan="2"><div align="center"><img src="file:///oakpark.png" width="252" height="83"><I>"...The company where quality really counts"</I> <img src="/ssaib2.jpg" width="137" height="88"><img src="/ukassm.png" width="57" height="88"><img src="/ppt.jpg" width="45" height="100"></div></td>
  </tr>
  <tr>
    <td width="91%" height="47">
	<?php 
		echo($msg); 
	?>
	</td>
    <td width="9%"><form action="Mainpage.php" method="post" name="LOG OUT" id="LOG OUT">
      <p align="left"><input name="LOG OUT" type="submit" id="LOG OUT" value="LOG OUT"></p></form></td>
  </tr>
    <tr align="center" valign="middle">
    <td height="70%" colspan="2">
	<p>&nbsp;</p>
	<p class="style1">To go the the scheduler page</p>
	<p class="style1"> Please press the button below.</p>
	<form name="form1" method="post" action="scheduler.php">
	  <input name="btnSubmit" type="submit" id="btnSubmit" value="Scheduler Page">
	  </form>	<p class="style1">&nbsp;</p>
    </TR>
</table>

</body>
</html>
 
Back
Top Bottom