query($sql);
} catch(PDOException $e) {
echo $e->getMessage();
}
$sql = "SELECT * FROM module_students WHERE email LIKE '%".$email."%' AND password AND status LIKE 'active'";
$q = $DB->query($sql);
$q->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $q->fetch()){
$_SESSION["userloggedin"] = 'true';
$_SESSION["user_name"] = $row['name'];
$_SESSION["user_email"] = $row['email'];
}
header("Location: profile.html");
exit();
} else {
$msg .= '
Please add the same password again.
';
}
} else {
$sql = "SELECT COUNT(*) AS num FROM module_students WHERE email LIKE '%".$email."%' AND token LIKE '%".$token."%' AND status LIKE 'active'";
$stmt = $DB->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if($row['num'] == 1){
try {
$sql = "UPDATE module_students SET token='' WHERE email LIKE '%".$email."%' AND token LIKE '%".$token."%' AND status LIKE 'active'";
$sth = $DB->query($sql);
} catch(PDOException $e) {
echo $e->getMessage();
}
} else {
echo 'The token is expired !!!';
header("refresh:1;login.html");
exit;
}
}
?>