In the beginning, the script worked fine. I logged in, logged out, and was able to do that a number of times.
Now, I don't know what's happened. The page ends up blank and if it's not entirely blank, it shows some html but doesn't redirect. However, it's logging me in because I can go directly to the page I'm supposed to be redirected to by typing it in the address bar without being bounced back to the login page (did that make sense)?
I get that it must be something about my session, but I don't fully understand.
This is the login check script:
<?php
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name=""; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$uname=$_POST['uname'];
$pname=$_POST['pname'];
$uname = stripslashes($uname);
$pname = stripslashes($pname);
$uname = mysql_real_escape_string($uname);
$pname = mysql_real_escape_string($pname);
$sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pname'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("uname");
session_register("pname");
header("location:index.php");
echo " '<h2>Continue to the donor list</h2><br /><br />
<div id="login-box-name">
Return to the login screen?
</div>
<div id="login-box-field">
</div>
<div id="login-box-name2"><a href="index.php"><img src="images/continue-btn.png" /></a></div>
<div id="login-box-field2">
</div>
<br />
<span class="login-box-options">
</span>
<br />
<br />' ";
}
else {
echo " '<h2>Wrong Username or Password</h2><br /><br />
<div id="login-box-name">
Return to the login screen?
</div>
<div id="login-box-field">
</div>
<div id="login-box-name2"><a href="login.php"><img src="images/return-btn.png" /></a></div>
<div id="login-box-field2">
</div>
<br />
<span class="login-box-options">
</span>
<br />
<br />' ";
}
?>
These are the errors I've received:
[27-Nov-2011 17:52:59] PHP Warning: Cannot modify header information - headers already sent by (output started at /home4/folder/public_html/ccc/check.php:2) in /home4/folder/public_html/ccc/check.php on line 35
[27-Nov-2011 17:52:59] PHP Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0