Hi,
Thanks for you quick reply.
Im looking at writing a checkbox value into a file.
When the submit button is clicked I write the value to the file on a specific line.
Then I want to read the file after its been submitted and the value is read back onto that page. I'm finding when I submit that value the value changed in the text file (from checked to unchecked or vice versa) but the page after submittion doesn't change. Only when the page is manually refreshed does the value change.
I use the following to check the value of the text file:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="checkbox" name="ch1" value="DHCPY" <?php echo $lines[6]; ?> /> Yes
And use this to write the value to the file:
if (isset($_POST['Submit1']))
if ($_POST['ch1'] == 'DHCPY')
{$ch1 = $_POST['ch1'];
if ($ch1 == 'DHCPY')
{$char1 = 'checked';}
else {$char1 = 'unchecked';}
}
if (isset($_POST['Submit1'])) {
$data = "ip.txt";
$file = file($data);
$i = 6;
$yourArray = array($char1);
$row = explode(",",$file[$i]);
for ($j=0;$j<count($row);$j++) {
$row[$j] = $yourArray[$j];
}
$fp = fopen('ip.txt', 'r');
fseek($fp, 0);
$file[$i] =implode(",",$row);
$content = implode("",$file);
$open = fopen($data,"w");
fwrite($open,$content);
fclose($fp);
}
?>