I have two php pages one a register page and the other a sign in page. The server is running php 5 as well.
Link to these two pages
http://www.steveoatman.me/gallery/sign_in.php
http://www.steveoatman.me/gallery/reg_form.php
When I sign in or register I receive an error
Warning: Cannot modify header information - headers already sent by (output started at /home/soatman/public_html/gallery/sign_in.php:2) in /home/soatman/public_html/gallery/sign_in.php on line 77
My problem is with the head() tag and the session_start() tag. From my research I need to have the session_start() at the very first line in the script. Okay I understand this and moved it to the very first line.
I moved the session_start() tag to the top of the page. It works fine in Firefox but IE6 it is just showing a blank screen after you submit the form. Strange if I refresh the page at this point it redirects to the correct page and you are logged in.
I believe this is a browser problem but can not find a way around this or a fix for this problem. This is a simple register and sign in script, so I am very confused. This same script did work about four months ago when I was in college.
This is a copy of just the sign in page at this time I can include the register page script as well if needed.
<?php session_start(); ?>
<?php ob_start(); //starts the output buffering ?>
<?php
//error reporting!
//Shows all possible problem!
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thomas A Oatman Sign In To Upload Images</title>
<link href="css/thomas.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtrHdr">
<div id="container">
<div id="header"> <a href="index.html"><img src="images/header.jpg" alt="Header Image" width="800" height="225" border="0" /></a>
<div id="nav">
<table id="" width="700" border="0" align="center" cellpadding="0" cellspacing="10" >
<tr align="center">
<td><a href="index.html" target="self">Home</a></td>
<td><a href="gallery2.html" target="self"> Image Gallery</a></td>
<td><a href="slideshow.php" target="self">Image Slide Show</a></td>
<td><a href="eulogy.php" target="self">Eulogy</a></td>
<td><a href="sign_in.php" target="_self">Upload Images</a></td>
</tr>
</table>
<!-- end #nav --></div>
<!-- end #header --></div>
<div id="mainContent">
<div id="signIn">
<h2>Our Sign In Form</h2>
<p><a href="reg_form.php">not registered</a>
<p>This is a secured area for user to register/sign in and upload images to this gallery and slide-show for Thomas A Oatman.</p>
<p>Once logged in you will be able to select an image on your computer and upload that image.<br />
That image will then be automatically added to the gallery and slide-show!<br />
Please use your Email and PassWord you choose when you registered!</p>
<?php //sign in page
// Check if the form has been submitted:
if (isset ($_POST['submit'])) { // Handle the form.
$loggedin = FALSE; // Not currently logged in.
// Open the file.
$fp = fopen ('users/users.txt', 'rb');
// Loop through the file.
while ( $line = fgetcsv ($fp, 100, "\t")) {
// Check the file data against the submitted data.
if ( ($line[0] == $POST['email']) AND ($line[1] == crypt ($POST['passWord'], $line[1]) ) ) {
$loggedin = TRUE; // Correct username/password combination.
// Stop looping through the file.
break;
} // End of IF.
} // End of WHILE.
fclose ($fp); // Close the file.
// Print a message.
if ($loggedin) {
$_SESSION['email'] = $_POST['email'];
$_SESSION['signin'] = TRUE;
ob_end_clean();
header('Location: user.php');
exit();
} else {
print '<p class="error" >The email and password you entered do not match those on file. Please try again, if you are still having problems, send an email to steve@steveoatman.me</p>';
?>
<form action="sign_in.php" method="post">
<table width="400" border="0" align="center" cellpadding="5">
<tr>
<td align="right">Email:</td>
<td align="left"><input type="text" name="email" size="40" /></td>
</tr>
<tr>
<td align="right">Password:</td>
<td align="left"><input type="password" name="passWord" size="20" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Sign In" /></td>
</tr>
</table>
</form>
<?php
} // Display the form again if not validated
} else { // Display the form.
// Leave PHP and display the form.
?>
<form action="sign_in.php" method="post">
<table width="400" border="0" align="center" cellpadding="5">
<tr>
<td align="right">Email:</td>
<td align="left"><input type="text" name="email" size="40" /></td>
</tr>
<tr>
<td align="right">Password:</td>
<td align="left"><input type="password" name="passWord" size="20" /></td>
</tr>
<tr>
<td> </td>
<td align="left"><input type="submit" name="submit" value="Sign In" /></td>
</tr>
</table>
</form>
<?php
}// End of SUBMIT IF.
?>
<!-- end of #signIn--></div>
<!-- end #mainContent --></div>
<div id="footer">
<p>Copyright © 2009 [SteveOatman.me]. All rights reserved.<br />
WEB DESIGNING DONE BY www.SteveOatman.me
</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>