Ciao a tutti, posso chiedervi un aiutino su questo codice?:
Codice PHP:
<?php
include_once 'newuser.class.php';
class NewPassword extends NewUser
{
public function SendPassword()
{
if($this->EmailCheckEmpty())
{
$_SESSION['erremail']=1;
header("Location: ?page=new_pass");
die;
}
elseif($this->EmailCheckCorrect())
{
$_SESSION['erremail']=2;
header("Location: ?page=new_pass");
die;
}
elseif($this->EmailExists())
{
$tempmail = $_POST[email];
$query_mail = "SELECT ver FROM users WHERE email=$tempmail";
$result_mail = mysql_query($query_mail,$connect);
while ( $row = mysql_fetch_array($result_mail, MYSQL_ASSOC) )
{
$vercheck = $row['ver'];
}
if($vercheck=='1'){
$newkey = $this->GetKey();
$this->DbConnect();
$query = "UPDATE users SET key_control='$newkey' WHERE email='$_POST[email]'";
mysql_query($query,$this->conn);
mysql_close($this->conn);
$body = "Starfantasy\r\n\r\n";
$body = "Hai richiesto una nuova password. Clicca sul link quì in basso per modificare la tua password:\r\n\r\n";
$body .= "http://www.sit.it/?page=change&pass=" . $newkey;
mail($_POST['email'], "Richiesta nuova password", $body, "From: io<miomail@me.com>");
header("Location: ?page=newpass_ok");
mysql_close($this->conn);
session_destroy();
return;
}
else
{
$_SESSION['erremail']=5;
header("Location: ?page=new_pass");
die;
}
}
else
{
$_SESSION['erremail']=4;
header("Location: ?page=new_pass");
die;
}
}
?>
In pratica fa alcuni controlli, ma quello che mi interessa è verificare se il campo ver nella tabella users del database sia impostato a 1. - dopo: elseif($this->EmailExists()) -
Se si, esegui lo script, se no $_SESSION['erremail']=5;
Il problema è che anche se l'utente ha impostato 1 nel campo ver salta l'if e va direttamente ell'else ( $_SESSION['erremail']=5; )
Non capisco, c'è qualche errore di scrittura? (abbiate pietà, sono novello)