<?php

    session_start
();
    
    
// where we came from
    
$referer =  'demo.php';

    
// instantiate and save the form values
    
require_once 'postToSession.php';
    
$session = new postToSession'_formValues' );
    
$session->serializePost();
    
    
// validate the input and set error messages
    
if( !is_numeric$_POST['number'] ) )
        
$errorMsg 'That was not a number.';
    elseif( empty( 
$_POST['text'] ) )
        
$errorMsg 'You didn\'t enter any text.';
        
    if( isset( 
$errorMsg ) ) {
        
// didn't pass validation so send them back with thier entered values
        
$redirect $referer '?&failed';
        
$_SESSION['_statusMsg'] = $errorMsg;
    }else{
        
//  passed validation here is where you would clean the input and do your database work
        
$redirect $referer '?&passed';
        
$_SESSION['_statusMsg'] = 'Nice work, gold star for you.';
    }

    
header"Location: $redirect" );
    exit;    
    
?>