Problemi di login II parte
attivautente.php
Codice PHP:
<?php
require_once("connetti.php");
//$email = $email;
$email = $_GET['email'];
echo "<h1> Attivazione account $email ... </h1>";
$qry="UPDATE utenti SET attivo='1' WHERE email='".$email."';";
if (mysql_query($qry)) {
echo "... Account $email attivato";
header("Refresh: 3;URL=paginaris.php");
// header("Refresh: 3;URL=login.php");
header("Refresh: 3;URL=login.php");
} else {
echo "Errore: account non attivato";
}
?>
login.php
Codice PHP:
<?php
require_once("connetti.php");
if (!isset($_POST['log'])) {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Loggati</title>
<center> <H2>DIGITARE USERNAME & PASSWORD. PREMERE <a href="iscrizione.php"> QUI</a> </H2>
<form action= '' method="POST">
<font face="Comic Sans MS">
Username: <input type="text" name="username" maxlength="30" size ="32"> <br> <br>
Password: <input type="password" name="password" maxlength="12" size ="14"> <br> <br>
</font>
<center>
<input type="submit" name="log" value="Loggati" />
</center> </form>
</head>
</body>
<?php
session_start();
//Query originale
// $query = "SELECT id,username, nome, attivo FROM utenti WHERE username='" . $_POST['username'] . "' AND password='" . md5($_POST['password']) . "' AND attivo ='1'";
} else {
$query = "SELECT username, attivo, password FROM utenti WHERE username='" . $_POST['username'] . "' AND password='" . md5($_POST['password']) . "' AND attivo ='1'";
$cerco = mysql_query($query);
if (!isset($_POST['esci'])) {
if (!$cerco) {
echo "Errore query: <br/>$query<br/>" . mysql_error();
mysql_error();
} else {
if (mysql_num_rows($cerco) == 0) {
$row = mysql_fetch_assoc($cerco);
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $row['password'];
$_SESSION['attivo'] = $row['attivo'];
$_SESSION['attivo'] = 1;
header("Refresh: 0;URL=paginaris.php");
} else {
echo "<h2> <center>";
echo 'Premere su <a href="java-script:history.back();">back</a> Indietro per riprovare </h2>';
echo "Utente non trovato";
header("Refresh: 10;URL=login.php");
echo "</h2> </center>";
}
}
}
}
?>
paginaris.php
Codice PHP:
<link rel="stylesheet" type="text/css" href="coloredisfondo.css">
<?php
require_once("connetti.php");
session_start();
if(isset($_COOKIE["ultimoaccesso"])) {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$ultimo_cookie = $_COOKIE["ultimoaccesso"];
$me= "Il tuo ultimo accesso è stato il: $ultimo_cookie";
} else {
$valore_cookie = date("d/m/Y - H:i:s");
setcookie ("ultimoaccesso", $valore_cookie, time() + 365 *24*3600);
$me= "Non ti sei mai collegato a questa pagina";
}
$stringa= strtoupper($_SESSION['nome']);
if(isset($_SESSION['nome'])) {
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>benvenuto</title>
<body>
<?php
require_once("connetti.php");
session_start();
$stringa= strtoupper($_SESSION['nome']);
if (ifsset($_SESSION['nome'] = $nome)) {
//if(isset($_SESSION['nome'] )) {
echo "Ciao " . $_SESSION['nome'];
echo "Accesso non consentito";
}
echo "<div class=\"messaggio\"><h1>";
echo "BENVENUTO ".$stringa." <br />";
echo $me;
echo "</h1></div>";
echo "</body></html>";
}else{
header("Location:failed.html");
exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<center> <br> <br>
<input type="button" onClick="window.location.href='logout.php';" style='padding:10px' value="Logout" />
</center>
</body>
</html>
Questo è quanto, e questa è la frase di quando mi loggo:
Premere su back Indietro per riprovare
Utente non trovato
Mi potete dare una mano per favore ???? Sono settimane che ci sto dietro senza trovare una soluzione. Dove sbaglio ???? Grazie.