My scripts have been working correctly for some time. Today I decided to store the database access codes in a separate file to hopefully improve security. Then the header error bit me!!!
I have searched the issue on this forum and other forums and am familiar with most of the causes and solutions. My "include file" is all php and the offending script is also...no html..that I can find..no "white space"...that I can find.
The following is the edited include file:
Code:
<?
$username="username";
$password="xxxxxxxxxxxxxxxxxxx";
$databasehost="localhost";
$database = "dbname";
?>
Following is the pertinent portion of the offending script. Last header statement is causing the problem. Can anyone find the error... or my coding mishaps???
Code:
<?include "dbinfo.php";
global $session1;
mysql_connect($databasehost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$passedusername=mysql_real_escape_string($_POST['username']);
$passedpassword=mysql_real_escape_string($_POST['password']);
$hashedpassword = md5($passedpassword);
$query="SELECT * FROM current_members WHERE username ='$passedusername'AND password='$hashedpassword'";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num==0) {
mysql_close();
header ("Location:workinglogindisplay.php");
exit();
} else {
$i=0;
$UserID=mysql_result($result,$i,"id");
$UserName=mysql_result($result,$i,"username");
$RBS_date=mysql_result($result,$i,"RBS_date");
$AccessPermitted=mysql_result($result,$i,"AccessPermitted");
$session1=checkUser($UserID); //check to see if user is already logged in
if ($session1){
deleteSession($UserID);//Force the user out if already logged in
writeLog($UserID,$UserName,$RBS_date,'4');
$query="UPDATE current_members SET AccessPermitted = 0 WHERE id = $UserID";
mysql_query($query);
print "<p><center><b>Emergency system notice: Your account is already in use on this system.";
print "<br>For security reasons your account is now frozen.";
print "<br>Consult your system administrator to re-activate your account.</b></center>";
mysql_close();
//echo "session1 = #session1";
exit();
}else {
$session1=setSession($UserName,$RBS_date,$UserID,$AccessPermitted);
writeLog($UserID,$UserName,$RBS_date,'1');
mysql_close();
header ("Location:membershomepage.php?id=$UserID");
exit();
}
}
|