<?php
include("includes/connections.php");
if(isset($_POST['sign_in'])) {
$password = mysqli_real_escape_string($con,$_POST['pass']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$get_user = "SELECT * FROM users WHERE user_email = '$email' AND user_password = '$password'";
$run_user = mysqli_query($con,$get_user);
$check = mysqli_num_rows($run_user);
if ($check==1) {
$_SESSION['user_email']=$email;
echo "<script>window.open('welcome.php','_self');</script>";
}
else {
echo "<script>alert('Password or email is not correct');</script>";
echo "<script>window.open('index.php','_self');</script>";
}
}
?>
Это был один из дней, когда я начал изучать php. Я застрял здесь. Код кажется прекрасным, но он не запускает сеанс при регистрации или входе в систему. Он говорит Неопределенный индекс: user_email.Undefined index: user_email .. читать все остальные ответы. все еще не могу вычислить
<h1>welcome : <?php echo $_SESSION['user_email']; ?></h1>
Может ли кто-нибудь помочь?
Возможные дубликатом? [PHP: "Обратите внимание: Undefined переменной", "Обратите внимание: Undefined индекс" и "Извещение: Undefined смещение"] (http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – MrDarkLynx
[session_start()] (http://php.net/manual/en/function.session-start.php) – Mohammad
_Hint: _ Перед использованием любых сеансов необходимо иметь ['session_start()'] (http://php.net/manual/en/function.session-start.php). –