As always this is mega frudtrating as the procedure I am using has worked in the past. I have had to tweak it thouhg to have an intermediary formhandler that sits in between page1.php (the form) and page2.php (the feedback)
here is the formhandler- it is not inserting into the db though!!
<?php
include("include/session.php");
$_SESSION['formdata']=$_POST;
include("connect.php");
//array to hold form errors
$form_error = array();
//validate your form data
if(!isset($_POST['firstname'])){
$form_error[] = "No firstname entered";
}
if(!isset($_POST['secondname'])){
$form_error[] = "No secondname entered";
}
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_page1a_v1.php");
} else {
$username = $_SESSION['username'];
if(isset($_POST['submit'])){
// build main query from form part 1
$sql = "INSERT INTO qualityuser SET qualityuser_id = NULL ";
foreach ($_SESSION['formdata'] as $col =>$val ){
if($col <> 'submit'){
$sql .=", $col = '$val' ";
}
//remove the form_error session
unset($_SESSION['form_error']);
//define variables
$score_pol_proc = "0";
$score = "0";
$score = $score - 10;
//set up an array for the answer 'types'
$orgtype = array();
// add values, if they exist
if(isset($_POST['registeredcharity'])) { $orgtype[1] = $_POST['registeredcharity']; }
if(isset($_POST['incorporated'])) { $orgtype[2] = $_POST['incorporated']; }
if(isset($_POST['regionalassociation'])) { $orgtype[3] = $_POST['regionalassociation']; }
if(isset($_POST['regionalcharity'])) { $orgtype[4] = $_POST['regionalcharity']; }
if(isset($_POST['project'])) { $orgtype[5] = $_POST['project']; }
//score for organisation type
foreach($orgtype as $key=>$value)
{
if($value == "1")
{
$score = $score + 5;
}
else
{
$score = $score + 0;
}
}
//scores for nature of organisation
$orgnature = array();
if(isset($_POST['nature_selfhelp'])) { $orgnature[1] = $_POST['nature_selfhelp']; }
if(isset($_POST['nature_frontline'])) { $orgnature[2] = $_POST['nature_frontline']; }
if(isset($_POST['nature_intermediary'])) { $orgnature[3] = $_POST['nature_intermediary']; }
if(isset($_POST['nature_infrastructure'])) { $orgnature[4] = $_POST['nature_infrastructure']; }
if(isset($_POST['nature_partnership'])) { $orgnature[5] = $_POST['nature_partnership']; }
if($orgnature[1] == "1")
{
$score = $score + 5;
}
if($orgnature[2] == "1")
{
$score = $score + 5;
}
if($orgnature[3] == "1")
{
$score = $score + 10;
}
if($orgnature[4] == "1")
{
$score = $score + 10;
}
if($orgnature[5] == "1")
{
$score = $score + 15;
}
// scores for number of staff/volunteers
$numstaff = array();
if(isset($_POST['involved_commitee'])) { $numstaff[1] = $_POST['involved_commitee']; }
if(isset($_POST['involved_volunteers'])) { $numstaff[2] = $_POST['involved_volunteers']; }
if(isset($_POST['involved_paid'])) { $numstaff[3] = $_POST['involved_paid']; }
foreach($numstaff as $key=>$value)
{
if($value == "5 or less")
{
$score = $score + 2;
}
if($value == "6 to 10")
{
$score = $score + 4;
}
if($value == "11 to 25")
{
$score = $score + 6;
}
if($value == "26 to 50")
{
$score = $score + 8;
}
if($value == "Over 50")
{
$score = $score + 10;
}
}
// add another 10 points for 5 or more volunteers
if ($numstaff[2] = "6 to 10" || "11 to 25" || "26 to 50" || "50 and over")
$score = $score + 10;
//scoring for funding
$fundingscore = array();
// add values, if they exist
if(isset($_POST['funded_unrestrictedfunds'])) { $fundingscore[1] = $_POST['funded_unrestrictedfunds']; }
if(isset($_POST['funded_localcouncil'])) { $fundingscore[2] = $_POST['funded_localcouncil']; }
if(isset($_POST['funded_undercontract'])) { $fundingscore[3] = $_POST['funded_undercontract']; }
if(isset($_POST['funded_grants_fees'])) { $fundingscore[4] = $_POST['funded_grants_fees']; }
if(isset($_POST['funded_socialenterprise'])) { $fundingscore[5] = $_POST['funded_socialenterprise']; }
if($fundingscore[1] == "1")
{
$score = $score + 5;
}
if($fundingscore[2] == "1")
{
$score = $score + 10;
}
if($fundingscore[3] == "1")
{
$score = $score + 10;
}
if($fundingscore[4] == "1")
{
$score = $score + 0;
}
if($fundingscore[5] == "1")
{
$score = $score + 5;
}
//scoring for organisation activities
$orgactivity = array();
if(isset($_POST['activity_care'])) { $orgactivity[1] = $_POST['activity_care']; }
if(isset($_POST['activity_advice_individual'])) { $orgactivity[2] = $_POST['activity_advice_individual']; }
if(isset($_POST['activity_advice_organisations'])) { $orgactivity[3] = $_POST['activity_advice_organisations']; }
if(isset($_POST['activity_specialist'])) { $orgactivity[4] = $_POST['activity_specialist']; }
if(isset($_POST['activity_community'])) { $orgactivity[5] = $_POST['activity_community']; }
if(isset($_POST['activity_awareness'])) { $orgactivity[6] = $_POST['activity_awareness']; }
if(isset($_POST['activity_sport'])) { $orgactivity[7] = $_POST['activity_sport']; }
if(isset($_POST['activity_mutual_support'])) { $orgactivity[8] = $_POST['activity_mutual_support']; }
if ($orgactivity[1] || $orgactivity[2] || $orgactivity[3] =="1")
$score = $score + 20;
if ($orgactivity[4] || $orgactivity[5] || $orgactivity[6] =="1")
$score = $score + 10;
if ($orgactivity[7] || $orgactivity[8] =="1")
$score = $score + 5;
// scoring for policies and procedures- this is a separate variable score as the total will be taken off the
//total of $score sub total
$pol_proc = array();
if(isset($_POST['have_policies_procedures'])) { $pol_proc[1] = $_POST['have_policies_procedures']; }
if(isset($_POST['have_management_structure'])) { $pol_proc[2] = $_POST['have_management_structure']; }
if(isset($_POST['have_communication'])) { $pol_proc[3] = $_POST['have_communication']; }
if(isset($_POST['have_supervision'])) { $pol_proc[4] = $_POST['have_supervision']; }
if(isset($_POST['have_strategy'])) { $pol_proc[5] = $_POST['have_strategy']; }
if(isset($_POST['have_aims'])) { $pol_proc[6] = $_POST['have_aims']; }
if(isset($_POST['have_review'])) { $pol_proc[7] = $_POST['have_review']; }
if ($pol_proc[1] =="1")
$score_pol_proc = $score_pol_proc + 15;
if ($pol_proc[2] || $pol_proc[3] || $pol_proc[4] =="1")
$score_pol_proc = $score_pol_proc + 10;
if ($pol_proc[5] || $pol_proc[6] || $pol_proc[7] =="1")
$score_pol_proc = $score_pol_proc + 5;
// Create a grand total by taking $pol_proc_score away from $scorePrint the number of points:
//echo 'Score for section a is....<strong>'. $score . '</strong> points!';
//echo 'Score for section b is....<strong>'. $score_pol_proc . '</strong> points!';
$total_score = $score - $score_pol_proc - 10;
$_SESSION['total_score'] = $total_score;
//redirect to result display page
}
header("Location: http://www.mindseyemidlands.co.uk/notts_quality/info_resource/selfassess_page1b_v1.php");
}
}
?>