Good evening everyone. I know this question has been asked many many times, but I’m completely stuck. I just can’t figure out what is wrong with my code. It worked perfectly fine for 3 years (yes!) and now I get this error when I try to log in:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/witjassies.co.za/httpdocs/licenseholderslogin.php:5) in /var/www/vhosts/witjassies.co.za/httpdocs/licenseholderslogin.php on line 68
I am a TOTAL beginner when it comes to PHP (only know the very basics), so I really do need help as this is a client’s website.
Can someone please tell me what is wrong with this code:
<?php
session_start();
?>
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Die Witjassies & Little Lab Coats | License Holders Login</title>
<meta http-equiv="Content-type" content="text/html; charset=us-ascii" />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="Susan Venter" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div id="page-container">
<div id="header">
<?php
include "scripts/header.php";
?>
</div>
<div id="spacer">
</div>
<div id="left-panel">
<div class="box1">
<?php
include "scripts/menu.php";
?>
</div>
<div class="box2">
<?php
include "scripts/contact.php";
?>
</div>
</div>
<div id="right-panel">
<div class="box3">
<center>
<?php
mysql_connect('...')
or die ("Could not connect to mysql because ".mysql_error());
mysql_select_db('...')
or die ("Could not select database because ".mysql_error());
if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='".$_POST["username"]."' and password='".$_POST["password"]."'"))==1){
session_register("username");
$_SESSION['username']=$_POST["username"];
header("location:index.php");
}
else {
echo 'The username and password you entered are incorrect.';
}
?>
<br />
<a href="licenseholders.php">Please try again.</a>
</center>
</div>
<div class="box3">
<div class="text3">License Holders / Lisensiehouers</div><br />
<br />
<div class="text3">...</div>
<a href="mailto:...">...</a><br />
...<br />
<br />
<div class="text3">...</div>
<a href="mailto...">...</a><br />
...<br />
<br />
<div class="text3">...</div>
<br />
<div class="text3">...</div>
<br />
<br />
</div>
</div>
<div id="footer">
<?php
include "scripts/footer.php";
?>
</div>
</div>
</body>
</html>
I’d be forever grateful if someone could point me in the right direction!
Kind regards,
Susan