I am anew to php please help…
I am trying to collect a variable (in specific the counter I used in my loop) on a $_POST after I submit my form.
<form action="reportingTemplate.php" method="post">
<?php
function buildform() {
if (file_exists('textt.txt')){
$x = file_get_contents('textt.txt');
$y = explode("\r\n", $x);
$incr = 1;
foreach ($y as $value) {
$z = explode(",", $value);
writehtml($incr,$z[1],$z[2],$z[0]);
$incr++;
}
if ($incr < 15)
for ($incr = $incr; $incr<16; $incr++) {
writehtml($incr,"","","");
}
}
else
for ($increm = 1; $increm<16; $increm++) {
writehtml($increm,"","","");
}
}
?>
<input type="hidden" id="test" name"countt" value="<?php echo $incr; ?>"/> <!--error area -->
<input type="submit"/>
</form>
where I am getting my $_POST:
$the = $_POST["countt"];
echo $the;
Try it this way:
Declare
$incroutside the function, then announce that it’s a global variable you’re manipulating from inside functionbuildform()then you canechoit…