Ciao a tutti!
Ho un piccolo problema, non so se sia causato dalla pagina index.php e da logout.php, quando vado su logout.php non mi effettua il logout, adesso vi posto i sorgenti:
index.php
logout.phpCodice PHP:<!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>Benvenuto su FareAffari.it!</title>
<link type="text/css" rel="stylesheet" href="style.css" title="Style" media="all">
</head>
<body>
<div id="contenitore">
<div id="logo">
Logo
</div>
<div id="menu">
<?php
session_start(); // inizio della sessione
if($_SESSION['privilegi'] != 0) {
include("pannello_utente.php");
}elseif($_SESSION['privilegi'] != 1){
include("pannello_admin.php");
}else{
include("login.html");
}
?>
<br><br><br>
<br> <br> <br> <br> <br>
<?php
include("categorie.html");
?>
</div>
<div id="corpo">
<br><br>
</div>
</div>
</body>
</html>
login.htmlCodice PHP:<?PHP
session_start();
session_destroy();
header("Refresh: 2; URL=index.php");
echo "Logout effettuato con successo!";
?>
login_control.phpCodice HTML:<HTML> <HEAD> <TITLE>FareAffari - Login</TITLE> </HEAD> <BODY> <table border="0" cellspacing="1" cellpadding="0" width="230" align="left" bgcolor="#CCCFFF"><tbody> <tr><form action="login.php" method="post"><input name="phpMyAdmin" type="hidden" value="V0N0db6Fl62QWr6eBkly75xAGn3" /><td> <table border="0" cellspacing="1" cellpadding="3" width="100%" bgcolor="#CCFFFF"><tbody> <tr> <td width="61">Username</td> <td width="3">:</td> <td width="143"><input id="myusername" name="myusername" type="text" size="20"></td> </tr> <tr> <td width="61">Password</td> <td width="3">:</td> <td width="143"><input id="mypassword" name="mypassword" type="password" size="20"></td> </tr> <tr> <td></td> <td></td> <td><input name="login" type="submit" value="Login >>" /></td> <strong>Login Membri</strong> </tr> <tr> <td width="61">Non sei registrato?</td> <td width="3"></td> <td width="143"><a href="registrazione/registrazione.html">Registrati!</td> </tr> <tr> <td width="61">Password Dimenticata?</td> <td width="3"></td> <td width="143"><a href="pass_dimenticata.php">Recuperala!</td> </tr> </tbody></table> </td> </form></tr> </tbody></table> </BODY> </HTML>
Codice PHP:<?php
session_start(); // inizio della sessione
$host="localhost"; // Hostname
$username="archivionegozio1"; // Mysql username
$password=""; // Mysql password
$db_name="my_archivionegozio1"; //Nome del Database
$tbl_name="utenti"; // Nome della Tabella
// Procedimento per connettersi al Database
mysql_connect("$host", "$username", "$password")or die("Connessione Fallita.");
mysql_select_db("$db_name")or die("Database non trovato.");
$username = addslashes($_POST['myusername']);
$pass = addslashes($_POST['mypassword']);
//qui controlli se l'utente ha scritto nel campo se nn sai cm si fa chiedimi
$sql = "SELECT * FROM utenti WHERE username = '".$username."' AND password = '".$pass."'";
$query = mysql_query($sql) or die("errore nella query: ".mysql_error());
if(mysql_num_rows($query) == 1) {
$riga = mysql_fetch_array($query);
$_SESSION['privilegi'] = $riga['privilegi']; // qui hai il grado dell'utente loggato
$_SESSION['username'] = $riga['Username']; // qui l'username
$_SESSION['pass'] = $riga['Password']; // qui la password
header("Refresh: 0; URL=amministrazione/administrationmenu001tptp.php");
}else{
echo "Username o password incoretti";
header("Refresh: 2; URL=index.php");
}
?>

LinkBack URL
About LinkBacks


