At my main page i have the following code:
<?php
$required = array('post_question');
// making sure post field is not empty
$error = false;
foreach($required as $field) {
if (empty($_POST[$field])) {
$error = true;
}
}
if(isset($_POST['post_question'])){
if ($error) {
echo "please type your question and submit!";
} else {
session_start();
$ps = $_POST['post_question'];
$_SESSION['postquestion']=$_GET['ps'];
header("Location: http://localhost/voidportals/success.php");
}
}
?>
I have the corresponding form on same page.
<form action="" method="post">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3 col-sm-offset-3">
<input type="text" placeholder="ask your question!" class="assin assin-success assin-autosize" name="post_question">
<input type="submit">
</div>
</form>
and then as you see my php code runs and redirects to another php page
<?php
$pss = "";
session_start();
if(isset($_SESSION['ps'])){
$pss = $_SESSION['ps'];
}
echo $_SESSION['pss'];
?>
now the echo doesn't echo the pss. I have never used session before and have no clue what goes wrong.Can anybody help me.
I'm getting the following error:
undefined index pss error.