Page 1 of 1

two pages of forms

Posted: Mon Jul 28, 2008 6:38 pm
by junjustkim
I have two forms containing textboxes and checkboxes. At first, the users will fill up the two forms then display it by two forms as well with value. My code is after the first form fill up then goto process.php to assign the key's and value of post into array as well as the form2. My problem now is when it comes for the displaying of the result, only the form1 having a value but the form2 doesn't have. I tried to find out and the reason is in the output two forms which is displaying result, I was called the session respectively and after the session_start() the value of my array for the second form was lost. Does anyone could help me to fixed this problem. Any suggestion would greatly appreciated. Kindly check my code

two forms which user will fill up;
form1.php (action)

Code: Select all

</table><form method="post" action="../include/process.php">
form2.php (action)

Code: Select all

<form method="post" action="../include/process.php">
process.php

Code: Select all

<?
session_start();
$v_sbm = $_POST['next'];
if ($v_sbm == 'NEXT PAGE')
  {
    //reset ($_POST);
    $_SESSION['value_array_form1'] = $_POST;
    echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=../infinity2/index2.php\">";
  }
 
$v_sbm = $_POST['output'];
if ($v_sbm =='NEXT PAGE')
  {
    reset ($_POST);
    $_SESSION['value_array_form2'] = $_POST;
    echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=../form_output/submit_form1.php\">";   (output of form1)
  }
?>
session.php

Code: Select all

<?
session_start();
class session
{
   var $arr_val_form1 = array();
   var $arr_val_form2 = array();
   function session()
     {
       if(isset($_SESSION['value_array_form1']))
         { 
           $this->arr_val_form1 = $_SESSION['value_array_form1'];
           unset($_SESSION['value_array_form1']);
         }
       if(isset($_SESSION['value_array_form2']))
         {
           $this->arr_val_form2 = $_SESSION['value_array_form2'];
           unset($_SESSION['value_array_form2']);
         }
     }
   function getvalue($fld)
     {
       if(array_key_exists($fld,$this->arr_val_form1))
         return htmlspecialchars(stripslashes($this->arr_val_form1[$fld]));
     }
   function getvalue2($fld)
     {
       if(array_key_exists($fld,$this->arr_val_form2))
         return htmlspecialchars(stripslashes($this->arr_val_form2[$fld]));
     }   
     
   function getvaluechkbox($fldchkbox)
     {
       if ($this->getvalue($fldchkbox) == "on")
              echo '<img src="../images/img_check.jpg" width="15" height="15" align="absmiddle" />';
           else
              echo '<img src="../images/img_uncheck.jpg" width="15" height="15" align="absmiddle" />';       
     }
   function getvaluechkbox2($fldchkbox)
     {
       if ($this->getvalue2($fldchkbox) == "on")
              echo '<img src="../images/img_check.jpg" width="15" height="15" align="absmiddle" />';
           else
              echo '<img src="../images/img_uncheck.jpg" width="15" height="15" align="absmiddle" />';       
     }   
}
 
$session = new session;
 
?>
name of the output form
submit_form1.php
submit_form2.php

Re: two pages of forms

Posted: Thu Jul 31, 2008 2:44 pm
by ghurtado
Sorry, I read your post a couple of times but I am still having a little bit of trouble understanding your issue.

What exactly do you expect to happen?

What happens instead of that?

Re: two pages of forms

Posted: Thu Jul 31, 2008 9:13 pm
by junjustkim
sorry I forgot to post, it's already fixed.

thanks