Answer the question
In order to leave comments, you need to log in
Undefined index in Sessions please help?
Tell me, please, what is the problem?
Notice: Undefined index: telephone in
Notice: Undefined index: idUser in
$sql = "SELECT * FROM `users` WHERE mail = '$mail'";
$row = mysqli_query($db, $sql);
$res = mysqli_fetch_assoc($row);
if($mail == $res['mail'] && $password == $res['password']){
$_SESSION['id'] = $res['id'];
$_SESSION['fname'] = $res['fname'];
$_SESSION['lname'] = $res['lname'];
$_SESSION['telephone'] = $res['telephone'];
$_SESSION['idUser'] = $res['idUser'];
$_SESSION['mail'] = $res['mail'];
$_SESSION['password'] = $res['password'];
$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (60 * 60);
header("Location: ../personalPage.php");
}
<?php
session_start();
if (!isset($_SESSION['id'])) {
header("Location: index.php");
}
else{
$now = time();
if ($now > $_SESSION['expire']) {
session_destroy();
header("Location: index.php");
echo "
<script>
alert('Ձեր ժամանակն սպառվեց!');
window.location.href = 'index.php';
</script>
";
}
else{ ?>
<ul>
<li><a href="#?"><?= $_SESSION['fname'] . " " . $_SESSION['lname'];?></a></li>
<li>Հասցե - <a href="#">Qaghaq Armavir</a></li>
<li>Հեռ․ - <a href="#"> <?= $_SESSION['telephone'];?></a></li>
<li>Էլ․ հասցե - <a href="#"><?= $_SESSION['mail'];?></a></li>
<li>ID - <a href="#n"> <?= $_SESSION['idUser'];?></a></li>
</ul>
<?php
}
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question