Codice:
login.php
$username = $_POST["username"];
$password = $_POST["password"];
include "./connect.php";
$connect = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Impossibile stabilire una connessione al database SQL");
$database = mysql_select_db($mysql_data);
$query = mysql_query("SELECT * FROM utenti");
while ($riga = mysql_fetch_object($query)) {
if ($username == $riga->user AND $password == $riga->pass) {
setcookie("login", "logged", time() + 1800);
header("Location: admin/");
} else {
include "./includes/head.php";
echo "<title>Login non riuscito</title>\n</head>\n\n";
include "./includes/header.php";
echo "\n\n<td class=\"content\"><span style=\"font-weight: bold; font-size: 11px; text-transform: uppercase;\"><center>LOGIN NON EFFETTUATO: DISCREPANZA NEI DATI</center></span>";
include "./includes/footer.php";
}
}
mysql_free_result($query);
mysql_close($connect);
Codice:
logout.php
$destroy = setcookie("login", "logged", time() - 1800);
if ($destroy == 1) {
include "../includes/head.php";
echo "<title>Pannello di amministrazione sito</title>\n</head>\n\n";
include "../includes/header.php";
echo "\n\n<td class=\"content\">\n<table class=\"prodotti\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">\nLogout effettuato correttamente.<br />\nCliccare <a href=\"../index.php\">qui</a> per tornare alla home del sito.";
include "../includes/footer.php";
} else {
include "../includes/head.php";
echo "<title>Pannello di amministrazione sito</title>\n</head>\n\n";
include "../includes/header_admin.php";
echo "\n\n<td class=\"content\">\n<table class=\"prodotti\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">\nNon è stato possibile effettuare il logout";
include "../includes/footer.php";
}
^^