Ok, Here’s one of the pages that the insertion is not working. Also, the error handling does not work, even tho’ the code for both is exactly the same as on another page where both work.
[php]<?php
/**
- survey_p2.php
- Registered users only, Secure page for User Testing Survey
-
*/
ob_start();
require_once “includes/secure.php”;
if (!session_id()) session_start();
include “includes/formverifier.php”;
include “includes/formlib.php”;
main(“User Testing Survey, Page 2”);
// Control the operation of the page
function main($title = “”) {
$f = new FormLib(“error”, HORIZONTAL);
if (isset($_REQUEST[“submitTest4”])) {
checkForm($f);
if (!$f->isError()) { // data is OK
processData($f);
redirect(“survey_p3.php”);
}
}
include(“includes/header.php”);
showContent($title, $f);
include(“includes/footer.php”);
}
// Check the input form for errors
function checkForm(&$f) {
// Add code to test form values and record errors
$f->isEmpty(‘navEase’, “Please check yes or no.”);
$f->isEmpty(‘understandEase’, “Please check yes or no.”);
$f->isEmpty(‘findEase’, “Please check yes or no.”);
$f->isEmpty(‘readEase’, “Please check yes or no.”);
$f->isEmpty(‘colorEase’, “Please check yes or no.”);
}
function processData($f) {
// Process the verified data here.
// This is where you save data in the database.
require “includes/dbconvars.php”;
$dbCnx = mysql_connect($dbhost, $dbuser, $dbpwd)
or die(mysql_error());
mysql_select_db($dbname, $dbCnx)
or die(mysql_error());
// Process the first query
$navEase = trim($_REQUEST[“navEase”]);
$understandEase = trim($_REQUEST[“understandEase”]);
$findEase = trim($_REQUEST[“findEase”]);
$readEase = trim($_REQUEST[“readEase”]);
$colorEase = trim($_REQUEST[“colorEase”]);
$sql = "
INSERT INTO survey (navEase, understandEase, findEase, readEase, colorEase)
VALUES (’$navEase’, ‘$understandEase’, ‘$findEase’, ‘$readEase’, ‘$colorEase’);
";
// For debugging (remove when finished)
/*print_r($_REQUEST);
echo “
SQL: $sql
\n”;
die(“Stopped for testing”); // stop the redirect
*/
mysql_query($sql)
or die("Query failed: ".mysql_error());
// Process the next query
$navComments = trim($_REQUEST[“navComments”]);
$understandComments = trim($_REQUEST[“understandComments”]);
$findComments = trim($_REQUEST[“findComments”]);
$readComments = trim($_REQUEST[“readComments”]);
$colorComments = trim($_REQUEST[“colorComments”]);
$genComments = trim($_REQUEST[“genComments”]);
$sql = "
INSERT INTO surveycomments (navComments, understandComments, findComments, readComments, colorComments, genComments)
VALUES (’$navComments’, ‘$understandComments’, ‘$findComments’, ‘$readComments’, ‘$colorComments’, ‘$genComments’);
";
// For debugging (remove when finished)
/*print_r($_REQUEST);
echo “
SQL: $sql
\n”;
die(“Stopped for testing”); // stop the redirect
*/
mysql_query($sql)
or die("Query failed: ".mysql_error());
mysql_close($dbCnx);
}
// Display the content of the page
function showContent($title, $f) {
$username = “”;
if (isset($_SESSION[“username”])) {
$username = " ".$_SESSION[“username”];
}
echo<<<HTML
$title
Hello $username,
Please continue the Survey.
HTML;
?>
Answer a few questions about your experience visiting the Website.
<?php echo $f->formatOnError('navEase', 'Did you find the site easy to navigate? ') ?>
<?php
$list = array("Yes"=>"Y", "No"=>"N");
echo $f->makeRadioGroup('navEase', $list);
?>
<?php echo $f->showMessageOnError('navEase') ?>
<?php echo $f->formatOnError('navComments', 'If not, please tell us why. ') ?>
<?php echo $f->makeTextInput('navComments', 75) ?>
<?php echo $f->showMessageOnError('navComments') ?>
<?php echo $f->formatOnError('understandEase', 'Was the information easy to understand? ') ?>
<?php
$list = array("Yes"=>"Y", "No"=>"N");
echo $f->makeRadioGroup('understandEase', $list);
?>
<?php echo $f->showMessageOnError('understandEase') ?>
<?php echo $f->formatOnError('understandComments', 'If not, please tell us why. ') ?>
<?php echo $f->makeTextInput('understandComments', 75) ?>
<?php echo $f->showMessageOnError('understandComments') ?>
<?php echo $f->formatOnError('findEase', 'Was it easy to find what you were looking for? ') ?>
<?php
$list = array("Yes"=>"Y", "No"=>"N");
echo $f->makeRadioGroup('findEase', $list);
?>
<?php echo $f->showMessageOnError('findEase') ?>
<?php echo $f->formatOnError('findComments', 'If not, please tell us why. ') ?>
<?php echo $f->makeTextInput('findComments', 75) ?>
<?php echo $f->showMessageOnError('findComments') ?>
<?php echo $f->formatOnError('readEase', 'Was it easy to read the information? ') ?>
<?php
$list = array("Yes"=>"Y", "No"=>"N");
echo $f->makeRadioGroup('readEase', $list);
?>
<?php echo $f->showMessageOnError('readEase') ?>
<?php echo $f->formatOnError('readComments', 'If not, please tell us why. ') ?>
<?php echo $f->makeTextInput('readComments', 75) ?>
<?php echo $f->showMessageOnError('readComments') ?>
<?php echo $f->formatOnError('colorEase', 'Did you find the colors pleasing? ') ?>
<?php
$list = array("Yes"=>"Y", "No"=>"N");
echo $f->makeRadioGroup('colorEase', $list);
?>
<?php echo $f->showMessageOnError('colorEase') ?>
<?php echo $f->formatOnError('colorComments', 'If not, please tell us why. ') ?>
<?php echo $f->makeTextInput('colorComments', 75) ?>
<?php echo $f->showMessageOnError('colorComments') ?>
<?php echo $f->formatOnError('genComments', 'Do you have any other comments about the site? ') ?>
<?php echo $f->makeTextArea('genComments', 3, 75) ?>
<?php echo $f->showMessageOnError('genComments') ?>
<?php
}
?>
[/php]
None of the insertion code inserts anything from this page, but the form looks great on the web, and it looks like it would work.