Salve e scusate se vi faccio perdere tempo ma non capisco il perchè non mi fungono i cookie cioè non si creano.
ho 2 file login.php e ctrllogin.php
login.php:
Codice PHP:
<form name="loginform" method="post" action="ctrllogin.php">
<input type="hidden" name="click" value="ok_login" />
<label for="email_login" style="cursor:pointer;">E-mail:</label>[/b]</td>
<input id="email_login" name="email_login" type="text" class="newad" style="width:300px;" />
<label for="password_login" style="cursor:pointer;">Password:</label>[/b]</td>
<input id="password_login" name="password_login" type="password" class="newad" style="width:300px;" />
<input type="checkbox" name="open_login" id="open_login" value="open_login" />
<label for="open_login" style="cursor:pointer;"><strong class="txt13000">mantieni l'accesso[/b]</label>
<button type="submit" class="bt_ad_contact">Accedi</button>
ctrllogin.php:
Codice PHP:
ob_start();
if(@trim($_POST["click"])=="ok_login"){
require_once("../include/db.php");
$erremail=false;
$errpassword=false;
$email_login=trim($_POST["email_login"]);
$password_login=trim($_POST["password_login"]);
$open_login=trim(@$_POST["open_login"]);
$QueryE=mysql_query("Select Email from register Where Email='$email_login'") or die (mysql_error()." errore verifica email");
if(mysql_num_rows($QueryE) == 0) $erremail=true;
$QueryP=mysql_query("Select Password from register Where Password='$password_login'") or die (mysql_error()." errore verifica password");
if(mysql_num_rows($QueryP) == 0) $errpassword=true;
if($erremail==false && $errpassword==false){
$QueryIDU=mysql_query("Select IDUser from register Where Email='$email_login' AND Password='$password_login' AND Confirm='1'") or die (mysql_error()." errore estrazione iduser");
if(mysql_num_rows($QueryIDU) > 0){
$iduser=mysql_result($QueryIDU,0,0);
($open_login=="open_login") ? $time=time() + (3600 * 24 * 365) : $time=time() + (3600 * 24);
mysql_query("Update register SET LastLogin=Now() Where IDUser='$iduser'") or die (mysql_error()." errore aggiornamento LastLogin");
setcookie("IDU_AHRA",$iduser,$time,"/",0);
mysql_query("Update favorites SET IDUser='$iduser' Where IDUser='$_COOKIE[IDPROV_AHRA]'") or die (mysql_error()." errore modifica IDUser in favorites");
setcookie("IDPROV_AHRA","",time() - 9999,"/",0);
header("location: my-area");
}else{
unset($_COOKIE["IDU_AHRA"]);
setcookie("IDU_AHRA","",-9999,"/");
$QueryIDU=mysql_query("Select IDUser from register Where Email='$email_login' AND Password='$password_login'") or die (mysql_error()." errore estrazione iduser per conferma");
$iduser=mysql_result($QueryIDU,0,0);
header("location: accesso&err=true");
}
}
mysql_close($dbconn);
}else{
header("location: accesso");
}
ob_end_flush();
il problema e che non mi crea il cookie