Help with usin checkboxes
Posted: Mon May 15, 2006 9:09 am
Hi can anyone help with this...
What im after is to be able to select several checkboxes and depending upon the selections these are added to a flat text file..
Code Follows
What im after is to be able to select several checkboxes and depending upon the selections these are added to a flat text file..
Code Follows
Code: Select all
<?php
$file_name = "test.txt";
$fp = fopen($file_name, "r");
echo "<br><form action='$_SERVER[PHP_SELF]'>";
while($line = fgets($fp))
{
echo "<input name='$line' type='checkbox' value='$line'>$line<br>";
}
echo "<br>";
fclose($fp);
echo "<input type='submit'>";
?>
<HR>
<?
if (isset($_POST['submit'])) {
$name = $_POST['$line'];
$fp = fopen("list.txt", "a");
if(!$fp) {
echo 'Error, the file could not be opened';
exit;
}
fwrite($fp, $name."n");
}
?>