Form Processor
PHP Code Examples
[Download]
<?php include '../util.inc'; 
      include 'surcom.inc'; 

// Open the database.
$dbm = dba_open("$surv_loc/results", "c", 'db4');
if(!$dbm) 
	whap('Database Open Failed',
	     'We are sorry, but your survey could not be recorded ' .
	     'due to trouble on the server.  Please try again ' .
	     'later.');

// Go through an update the counts.
$surv_path_info = $_POST['surv_path_info'];
foreach($_POST as $var => $val) {
	if(!preg_match('/^ques_([0-9]+)$/', $var, $parts)) continue;
	$key = $surv_path_info . '+' . $parts[1] . '+' . $val;
	if(dba_exists($key, $dbm))
		$count = dba_fetch($key, $dbm) + 1;
	else
		$count = 1;
	dba_replace($key, $count, $dbm);
}

dba_close($dbm);

start('Thank You');
echo "Your survey has been recorded.  If you like, you may see the ",
	"<a href=\"surshow.php/$surv_path_info\">",
	"current results</a>.";
?>
</body>
</html>