When I pass data through a post or session, not everything gets passed in all cases (post or session). I am attempting to trace down my error. The flow is edit.php -> process.php calls newsHandler class -> (edit.php or main.php).
When the form on edit.php is processed, I can print out an array, but my form is never update because ID never makes it to the function. (this appears to be a post) When I do a refresh, I lose all array info (this appears to be a session).
On the initial form, I have the following:
if (isset($_SESSION['value_array']['id'])) {
//print_r($_SESSION['value_array']);
$id = $_SESSION['value_array']['id'];
} else {
$id = $_POST['id'];
}
...which is all later unset at the end of the page.
Then, we make the form direct to process.php:
if (preg_match("/status=edit/i", $prevreferer)) {
$data = $newsHandler->editArticle($id,$postedValue,$displaydate);
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $newsHandler->error;
if($data == false) {
header("Location: ".$session->referrer."");
exit;
} else {
header("Location: http://localhost/steelfacts/admin/main.php");
exit;
}
Within process.php, we make a call to a function editArticle within a class:
function editArticle($id,$text,$displaydate='') {
if (isset($_SESSION['value_array']['id'])) {
$postArray = array(
'id' => $_SESSION['value_array']['id'],
'text' => $_SESSION['value_array']['text'],
'display_date' => $_SESSION['value_array']['displaydate']
);
$setaction = "session";
} elseif ( isset( $_POST ) ) {
$postArray = &$_POST ; // 4.1.0 or later, use $_POST
$setaction = "post";
} else {
$postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS
$setaction = "http_post_vars";
}
//echo $setaction . "<br /><br />";
//print_r($postArray);
foreach ( $postArray as $sForm => $value )
{
if ( get_magic_quotes_gpc() ) {
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
} else {
$postedValue = htmlspecialchars( $value ) ;
}
}
//print_r($postedValue);
Can someone set me straight on my use of sessions here?