隐藏的HTML表单字段保存状态

So I've been at this a while. Too long... The problem I'm having is that all the hidden value fields change too the input you just put in (at least according to the source code).

This is how I’m trying to change them..(6 of these for a count, avg etc.)

<input type="hidden" name="sum" value="<?php print $sum ?>" />

This is the php file

<?php
$input = htmlspecialchars($_POST['num']);

    $tempray = array($input);

//Also tried things like $sum = $sum + $input but no luck
    $sum = array_sum($tempray);
    $count = count($tempray);
    $avg = ($sum/$count);
    $max = max($tempray);
    $min = min($tempray);
    $posint = $poscount;

    if( is_int( $input ) and $input >= 0 and $input % 2 == 0 ) {
        $poscount = $poscount + 1;
    }

    if ($input != 0 AND $input != null){
    include 'index.html.php';
    }else{
    include 'results/index.html.php';
    }

    ?>

Not sure why this wouldn't work?