e cosa devo fare allroa, dato che register_globals deve stare su off?
ho messo hai detto tu quello che mancava come puoi vedere il codice sotto
login.php
Codice PHP:
<?php
session_start();
include("db_vars.inc");
//Sanitize the value received from login field
//to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
$username=mysql_real_escape_string($_POST['username']);
}else {
$username=$_POST['username'];
}
//Create query
$qry="SELECT iduser FROM users WHERE username='$username' AND password='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result)>0) {
//Login Successful
$member=mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID']= $member['iduser'];
$_SESSION['username'] = $username;
session_write_close();
echo "Ciao $username";
}else {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
[b]Login utente[/b]
Username:<input type="text" name="username" />
Password:<input type="text" name="password" />
<input type="submit" />
</form>
<?
}
}
?>
header.php
Codice PHP:
<table border="1" height="90">
<tr>
<td width="200" valign="top">[url="index.php"]index.php[/url]
</td>
<td width="400">[url="logout.php"]logout.php[/url]
</td>
<td width="200" valign="top">
<?
//Start session
//print_r($_SESSION);
if(empty($_SESSION['SESS_MEMBER_ID']) ) {
include ('login.php');
} else {
echo "Ciao $username";
}
?>
</td>
</tr>
</table>
index.php
Codice PHP:
<?
//Start session
session_start();
print_r($_SESSION);
echo "Ciao $username";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title> New Document </title>
</head>
<body>
<table width="800" height="600" border="1">
<tr>
<td height="100"><? include ('header.php') ?></td>
</tr>
<tr>
<td><? include ('body.php') ?></td>
</tr>
<tr>
<td height="60"><? include ('footer.php') ?></td>
</tr>
</table>
</body>
</html>