I'm having some trouble with my sessions only working once through a form. Any tips on what I may be missing?
edit.php: The form initially sets up the ID of the item in question.
//get the article to edit
if (isset($_POST) && !empty($_POST)) {
$id = $_POST['id'];
} elseif (isset($_SESSION)) {
$id = $_SESSION['id'];
}
Upon first submission of the form, process.php handles the processing behind the scenes, and returns it to the referring page.
if (preg_match("/status=edit/i", $prevreferer)) {
// if (isset($_POST['id'])) {
// $id = $_POST['id'];
// } elseif (isset($_SESSION)) {
// $id = $_SESSION['id'];
// }
$id = $_SESSION['id'];
print_r($_SESSION);
print_r($_POST);
$data = $newsHandler->editArticle($id,$postedValue,$displaydate);
if($data == false) {
//$_SESSION['id'] = $id;
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $newsHandler->error;
//header("Location: ".$session->referrer."");
//flush();
exit;
} else {
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $newsHandler->error;
header("Location: http://localhost/steelfacts/admin/main.php");
//flush();
exit;
}
We return to the referring page (edit.php), and it displays the new changes. On a second submit, however, despite the ID existing, no changes ever show up.