Forum Moderators: coopster

Message Too Old, No Replies

troubled post/form/include/session code

can you guys save my hair and figure what is wrong

         

Sarah Atkinson

6:09 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



I can't get it past displaying form1.
But even if I run form1 with a change to the action the Sessions still don't work.


<?php
require('sess.inc.php');
if (isset($_POST['scheck'])) {
$activitiesarray=Array();
foreach ($_POST as $key => $val) {
$activitiesarray[$key] = $val;
}
$_SESSION['activityform'] = $activitiesarray;
}
elseif (isset($_POST['from1check'])) {
$form1array=Array();
foreach ($_POST as $key => $val) {
$form1array[$key] = $val;}
$_SESSION['form1']= $form1array;
}
?>


<?php
require_once 'db.inc.php';
if(!isset($_SESSION['form1'])){
include 'form1.php';
}
elseif(!isset($_SESSION['activityform'])){
include 'schedule.inc.php';
}else{
print_r($_SESSION);
}
?>

mercnboy3

6:30 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



You may need to put session_start() at the very top of the page. Before any output.

Sarah Atkinson

8:34 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



it is located in the
sess.inc.php file

jatar_k

8:36 pm on Jun 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sorry Sarah, I am missing the point

do you mean

if(!isset($_SESSION['form1'])){

is always evaluating true and you can't make it hit the else if or the else?

Sarah Atkinson

8:44 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



I'm saying if the form1 in $_SESSION is not(!) set the include the form1.inc.php

if it is set then don't include form1 but rather include schedule.inc.php

I thought aboult doing away with the sessions totaly and jjust passing all the data from each form with hidden inputs but that just seems like a lot of work and a good place for errors to wait. Although now I'm thinking it may have been faster to do it that way.