ciao,
sto costruendo un questionario on line e vorrei che ad una certa domanda se hai risposto si prosegui con il questionario ma ne caso in cui rispondi no, i dati venissero inviati in db.
io ho creato una pagina filtro (vi posto il codice) ma mi da errore, in cosa sbaglio?
avete eventualmente un idea alternativa?
posso fare un controllo sul valore della variabile che mi interessa e effettuare i vari comportamenti in base al valore della variabile stessa?

mi scuso se non sono stato chiaro, ma spero che possiate aiutarmi ugualmente.

codice:
<?php session_start ();
$HTTP_SESSION_VARS['acqfrutta'] = $HTTP_POST_VARS['acqfrutta'];
$HTTP_SESSION_VARS['noacqfrutta'] = $HTTP_POST_VARS['noacqfrutta'];
?>
<?php 
header('Cache-Control: Private'); 
?> 
<?php if ($HTTP_SESSION_VARS['manarance'] == "2");  
               
 { <?php require_once('../../../Connections/quest.php'); ?> ?> 
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO fineanticipato (acqfrutta, acqarance, manfrutta, manarance, noacqfrutta, noacqarance, nomanfrutta, nomanarance, somministrazione) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($HTTP_POST_VARS['acqfrutta'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['acqarance'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['manfrutta'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['manarance'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['noacqfrutta'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['noacqarance'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nomanfrutta'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nomanarance'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['somministrazione'], "int"));

  mysql_select_db($database_quest, $quest);
  $Result1 = mysql_query($insertSQL, $quest) or die(mysql_error());

  $insertGoTo = "../d1.php";
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
} 
else { header('Location: d2.php');}?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>questionario</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FF9900" text="#336600" link="#FF0000" vlink="#000000">
<div align="center"> </div>
<div align="center">
  <form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
    <font color="#000000"><font face="Georgia, Times New Roman, Times, serif"> 
    <input name="manarance" type="hidden" id="manarance" value="<?php echo $HTTP_SESSION_VARS['manarance']; ?>">
    </font><font color="#000000"><font face="Georgia, Times New Roman, Times, serif"> 
    <input name="nomanarance" type="hidden" id="nomanarance" value="<?php echo $HTTP_SESSION_VARS['nomanarance']; ?>">
    </font></font><font face="Georgia, Times New Roman, Times, serif"> 
    <input name="manfrutta" type="hidden" id="manfrutta" value="<?php echo $HTTP_SESSION_VARS['manfrutta']; ?>">
    <input name="nomanfrutta" type="hidden" id="nomanfrutta" value="<?php echo $HTTP_SESSION_VARS['nomanfrutta']; ?>">
    <input name="acqarance" type="hidden" id="acqarance" value="<?php echo $HTTP_SESSION_VARS['acqarance']; ?>">
    <input name="noacqarance" type="hidden" id="noacqarance" value="<?php echo $HTTP_SESSION_VARS['noacqarance']; ?>">
    <input name="somministrazione" type="hidden" id="somministrazione" value="1">
    <input name="acqfrutta" type="hidden" id="acqfrutta" value="<?php echo $HTTP_SESSION_VARS['acqfrutta']; ?>">
    <input name="noacqfrutta" type="hidden" id="noacqfrutta" value="<?php echo $HTTP_SESSION_VARS['noacqfrutta']; ?>">
    </font></font> 
    <input type="hidden" name="MM_insert" value="form1">
  </form>
  <font color="#000000"><font face="Georgia, Times New Roman, Times, serif"> 
  </font></font> </div>
</body>
</html>
tutte le altre variabili di sessione che non sono presenti ad inizio pagina sono state memorizzate precedentemente.