I am aware I have no vailidation or sanitziation. This will be added 😀
I currently have a php form which requests the following information:
- Avg. salary
- number of employees
- Pension Uptake PCT
- Pension Contributuin PCT
Which is then submitted, and proccessed by a file called SSESC.php (code will be below).
It should then return, the computed data to the field Total Employee contribution ($TEC) and Total Savings ($NISAVING)
I can get the data passed to the SSEC.php file, and it is processed (tested by echo) but I am unable to get the data back and displayed on the form.
Im attempting to save the data into a session, and then return and refill the form. Im returning from the script by using <?php header ("location: form.php");?>. this works but the form is not filled in. I will include the snippets below from the form.
SSESC.php code
<?php header ("location: form.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SSEC-Process</title>
</head>
<?php
setlocale(LC_MONETARY, 'en_GB');
$Average_Salary = $_POST["Average_Salary"];
$EMPNUM = $_POST["EMPNUM"];
$PUPCT = $_POST["PUPCT"];
$PCPCT = $_POST["PCPCT"];
$TEC = "";
$NI_save = "";
$employeepension = $PCPCT/100;
$pensionuptake = $PUPCT/100;
$TEC = $Average_Salary*$employeepension*$EMPNUM*$pensionuptake;
$combi = $TEC*13.8/100;
$NI_save = money_format('%.0i', $combi);
$_SESSION["TEC"] = money_format('%.0i',$TEC);
$_SESSION["NISAVE"] = $NI_save;
?>
<body>
</body>
</html>
Form Snippets
<input id="TEC" name="TEC" class="Label" type="text" maxlength="255" value="<?= $_SESSION['TEC']?>"/>
<input id="NI_save" name="NI_save" class="label" type="text" maxlength="255" value="<?=$_SESSION['NISAVE']?>"/>
Thanks in advance.
Steve.
session_start();on top of both of your scripts. (Both in this script and in form.php. Right at the top)header()call to the bottom of the processing script.