I've been developing in PHP for a few months now. Found a bump here and there and solved them. But now some recent events might have affected what I've been doing, so I've been looking for some answers. Here's the situation. I'll try to be as explicit as possible.
I've been making a PHP site that accesses a Postgres 7.4 database. Webpages and database have their own Linux server. Everything worked fine until today after a database upgrade (to Postgres 8.0) made during the weekend. I went to the login page, typed user and password, clicked the submit button, and the it started to load and kept loading, but never changed to the next one. I tried debugging, but no errors were found. I tried logging in using a backup of the webpages (also stored in the server with the ones that give me trouble) and voilá, I was in. I compared then the backup and the current version finding that the only difference between them was the use of session_start(). In fact, I removed that line from the current version file and I was able to acces it easily.
I asked the mantainer if the server containing the webpages was also upgraded/altered along with the Database server and the answer was no.
I also searched in the forums, and found a similar topic, but I couldn't see how that could apply in my case. If so, please do tell me.
I'd like to know if you could also indicate wether it's my bad or I need to check any of the servers.
Anyway, here's the code:
This is the login page
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<TITLE>User Login</TITLE>
<link rel="stylesheet" type="text/css" href="WebFormat.css">
</head>
<body id="login">
<form action="Menu_S.php" method=post >
<table>
<tr><td>
User:
</td></tr>
<tr><td>
<input type=text name=User>
</td></tr>
<tr><td>
Password
</td></tr>
<tr><td>
<input type=password name=Password>
</td></tr>
<tr><td>
<p> </p><input name=Tipo type=submit value="Log in">
</td></tr>
</table>
</form>
</body>
</html>Code: Select all
<?php
//if I remove this line, I can access the webpage, but have no access to the $_SESSION variables
session_start();
?>
<!doctype html public '-//W3C//DTD HTML 4.0//EN'
'http://www.w3.org/TR/REC-html40/strict.dtd'>
<html>
<style TYPE="text/css">
h1{
font-family:Verdana,Arial;
font-size:10pt;
text-align: center;
}
body{
text-align:left;
font-size: 10pt;
text-align: center;
font-family:Verdana, Arial;
}
</style>
<?php
include "Conection_S.php"; //Contains function to connect to database
include "TestPwd_S.php"; //Contains function that validates password
include "Logger_S.php"; //Contains function that creates a log of an event
include "DatePassword_S.php"; //Contains function that determines how much time a user's password is still valid, using a politics table in the database
include "Get_Data_S.php"; //Contains function that obtains the data of a user, given their login and password
include "Session_Upd_S.php"; //Updates the $_SESSION variables used in here
function Print_Menu($ID_Ext)
{
if(!isset($_SESSION['ID_User'],$_SESSION['type']))
exit();
$result=Get_Data($_SESSION['ID_Usuer'],$_SESSION['type']);
$fields=pg_fetch_array($result);
$Customer=1;
if (isset($fields['id_customer'])===true)
$Customer=$fields['id_customer'];
LogEvent($_SESSION['ID_User'],0,0,$Customer,1,$fields['id_user_type'],$ID_Ext);
$_SESSION['valid_days']=Valid_Password_Days($_SESSION['user_type'],$_SESSION['last_change_date']);
if (isset($fields['id_enterprise']))
$_SESSION['Permission']=$fields['id_enterprise'];
else
$_SESSION['Permission']=1;
print
'
<head>
<h1>'.$_SESSION['user_name'].'</h1>
<title>User Options</title>
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menu_items.php"></script>
<script language="JavaScript" src="menu_tpl.js"></script>
<link rel="stylesheet" href="menu.css">
';
if ($_SESSION['valid_days']<8)
print
'
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, \'" + id + "\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=300,left = 362,top = 234\');");
}
</script>
';
print
'
</head>
';
if ($_SESSION['valid_days']<8)
print
'
<body id="login" onLoad="javascript:popUp(\'reminder.php?Left='.$_SESSION['valid_days'].'&ID='.$_SESSION['ID_User'].'\')">
';
else
print
'
<body id="login">
';
print'
<script language="JavaScript">
new menu (MENU_ITEMS, MENU_TPL);
</script>
</body>
';
}
Connect($BDD);
if ($BDD)
{
//this part is for testing...
if (!isset($auto))
$how=0;
else
$how=1;
$result=Passw_Validate($User,$Password,how);
if ($result)
{
$fields=pg_fetch_array($result);
Update_Session_Vars($fields['id_user'],$fields['id_type'],$fields['user_name'],$fields['user_login'],$fields['masked'],$fields['email'],$fields['last_date_pwd_change'],$fields['id_class'],$ID_Ext);
Print_Menu($ID_Ext);
}
else
{
print '
<body id="login">
Invalid user or passoword.<br>
Please try again.<br>
<form action="Login_S.html" method=post target="Left" >
<input name=Back type=submit value="Back" target="Left">
</form>
</body>';
pg_close($BDD);
session_destroy();
}
}
else
print 'Impossible to retrieve data. Please try again.';
?>
</html>