I have set the session which is working but If I refresh the page then I am getting error
Undefined index: email_error
and if I clicked on submit button then it is working. I also set the empty but not working.
There is some issue in session.
php
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['email']=$_POST['email'];
$_SESSION['email_error']="";
if (empty($_SESSION['email'])) {
$_SESSION['email_error']="email is empty";
header('location:index.php');
}
}
?>
HTML
<?php
session_start();
$email_error="";
$email_error=$_SESSION['email_error'];
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="process.php" method="post">
<span class="error"><?php echo $email_error;?></span>
<input type="email" name="email">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
session_destroy();
?>