two pages of forms
Posted: Mon Jul 28, 2008 6:38 pm
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)
form2.php (action)
process.php
session.php
name of the output form
submit_form1.php
submit_form2.php
two forms which user will fill up;
form1.php (action)
Code: Select all
</table><form method="post" action="../include/process.php">Code: Select all
<form method="post" action="../include/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)
}
?>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;
?>submit_form1.php
submit_form2.php