Hmmm- not sure what to make of the results. I cannot see where the session is being destroyed. I think it may have something to do with 'formdata' but I have done a search for this and there is no instance of it only 'formdata1'.
here are my results
form part1
Array
(
[username] => test120107
[url] => /notts_quality/info_resource/selfassess_part2a_v1.php
[userid] => 6c8f3e2871019c8da0c016417b2d274c
[formdata1] =>
[formdata] =>
[total_score] => 41
[form_error] => Array
(
)
)
form part 2
Array
(
[username] => test120107
[url] => /notts_quality/info_resource/selfassess_part2b_v1.php
[userid] => 6c8f3e2871019c8da0c016417b2d274c
[formdata1] => Array
(
[time] => Flexible
[demand] => Low
[external_support] => Self assessment
[training] => Low
[complexity] => Low
[depth] => Low
[partuse] => Yes
[cost] => Low
[orgwhole] => Yes
[external_validated] => Yes
[submit] => submit
)
[formdata] =>
[total_score] => 41
[form_error] => Array
(
)
)
here is my code in it's totality
form part 1
<?php
include("include/session.php");
$_SESSION['formdata1']='';
include("connect.php");
// query
$sql = "SELECT * FROM qualityuser WHERE username = '".$username."'";
$result = mysql_query($sql);
// if we have rows, fetch them
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
} else {
$row = array('time'=>'','demand'=>'','external_support'=>'','training'=>'','complexity'=>'','depth'=>'','partuse'=>''
,'cost'=>'' ,'orgwhole'=>'','external_validated'=>'');
}
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
?>
/////////
///show form////
form handler (intermediate handler)
<?php
include("include/session.php");
if(isset($_POST['submit'])){
include("connect.php");
//array to hold form errors
$form_error = array();
//validate your form data
$time = trim($_POST['time'] );
if (strlen($firstname)==0) {
$form_error[] = "time not selected";
}
$demand = trim($_POST['demand'] );
if (strlen($secondname)==0) {
$form_error[] = "demand not selected";
}
if(count($form_error) > 0){
//hold the error in session so you can display the error in your form page.
$_SESSION['form_error'] = $form_error;
//redirect to the form
header("Location: http://www.mindseyemidlands.co.uk/notts_quality/info_resource/selfassess_part2a_v1.php");
} else {
$_SESSION['formdata1']=$_POST;
$username = $_SESSION['username'];
if (isset($_POST['submit'])) {
$answer = array();
$answer[1] = $_POST['time'];
$answer[2] = $_POST['demand'];
$answer[3] = $_POST['external_support'];
$answer[4] = $_POST['training'];
$answer[5] = $_POST['depth'];
$answer[6] = $_POST['partuse'];
$answer[7] = $_POST['cost'];
$answer[8] = $_POST['orgwhole'];
$answer[9] = $_POST['external_validated'];
function pqasso($answer)
{
$pqasso_score = 0;
//time needed
if ($answer[1] == "Flexible") {$pqasso_score = $pqasso_score + 1000;}
if ($answer[1] == "0-12 months") {$pqasso_score = $pqasso_score - 0;}
if ($answer[1] == "12 + months") {$pqasso_score = $pqasso_score - 0;}
//demand on staff time
if ($answer[2] == "Low") {$pqasso_score = $pqasso_score - 0;}
if ($answer[2] == "Medium") {$pqasso_score = $pqasso_score + 1000;}
if ($answer[2] == "High") {$pqasso_score = $pqasso_score - 0;}
////loads of php working out variable $score here too long to show!!//////
//etc
}
header("Location: http://www.mindseyemidlands.co.uk/notts_quality/info_resource/selfassess_part2b_v1.php");
?>
form part 2 (displays results)
<?php
include "include/session.php";
$username = $_SESSION['username'];
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
if (isset($_SESSION['username'])) {
include ("connect.php");
$getuser = mysql_real_escape_string($_SESSION['username']);
$sql = "SELECT * FROM qualityuserscores WHERE username = '$username' AND timeentered = NOW() ORDER BY score DESC";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
///////////////////////////////
echo '
<TABLE BORDER=1 CELLPADDING=2>
<TR> <TH COLSPAN=2 BGCOLOR="#99CCFF"></TH> </TR>
<TR> <TD WIDTH=400><a href="' . $row['search_url'] . '">' . $row['qualitysystem'] . '</a></TD> <TD WIDTH=250>' . $row['score'] . '</TD> </TR>
</TR>
</TABLE>';
}
}
}
?>