Just about complete but..............Help
Posted: Thu Dec 23, 2004 3:20 pm
Okay I have a textfile that I am looping thru and outputing the information to a new page.
Everything works great. But if you notice I am also displaying a checkbox with each line I post. This is so I can delete the line number/contents from the file.
Here lies the problem. It displays fine, but once I hit the submit button to my new page(for testing purposes before I actually remove the lines from the textfile) I can't seem to pass the information.
The new page(delete.php) should just show the lines that were checked. Note that I a am naming each checkbox the value of $j, which would be the line number from the textfile.
I hope this isn't too confusing. I am basically wondering how I would store the values of checkbox in an array and pass it to delete.php.
Here is what I have so far.
<form action="delete.php" method="post">
<?PHP
$dbfile = 'mytextfile.txt';
$contents = file($dbfile);
for ($i=1,$j=1;$i<count($contents);$i++,$j++){
implode("<br>\n",$getid = explode($SEP,trim($contents[$i]))).'<br>'.$i."<br><br>\n";
$email = $getid[3];
echo "<input type=\"text\" size=\"15\" name=\"firstname\" value=\"$getid[1]\">".
"<input type=\"text\" size=\"15\" name=\"lastname\" value=\"$getid[2]\">".
"<input type=\"text\" size=\"25\" name=\"email\" value=\"$getid[3]\">".
"<input type=\"text\" size=\"10\" name=\"account\" value=\"$getid[4]\">".
"<input type=\"text\" size=\"25\" name=\"accountid\" value=\"$getid[5]\">"." "." "." ".
"<input type=\"checkbox\" name=\"$j\">"."<br>";
}
?>
<p align="left"><input type="submit"
name="delete" value="delete"></p>
Any and all help would be greatly appreciated.
Thanks,
Everything works great. But if you notice I am also displaying a checkbox with each line I post. This is so I can delete the line number/contents from the file.
Here lies the problem. It displays fine, but once I hit the submit button to my new page(for testing purposes before I actually remove the lines from the textfile) I can't seem to pass the information.
The new page(delete.php) should just show the lines that were checked. Note that I a am naming each checkbox the value of $j, which would be the line number from the textfile.
I hope this isn't too confusing. I am basically wondering how I would store the values of checkbox in an array and pass it to delete.php.
Here is what I have so far.
<form action="delete.php" method="post">
<?PHP
$dbfile = 'mytextfile.txt';
$contents = file($dbfile);
for ($i=1,$j=1;$i<count($contents);$i++,$j++){
implode("<br>\n",$getid = explode($SEP,trim($contents[$i]))).'<br>'.$i."<br><br>\n";
$email = $getid[3];
echo "<input type=\"text\" size=\"15\" name=\"firstname\" value=\"$getid[1]\">".
"<input type=\"text\" size=\"15\" name=\"lastname\" value=\"$getid[2]\">".
"<input type=\"text\" size=\"25\" name=\"email\" value=\"$getid[3]\">".
"<input type=\"text\" size=\"10\" name=\"account\" value=\"$getid[4]\">".
"<input type=\"text\" size=\"25\" name=\"accountid\" value=\"$getid[5]\">"." "." "." ".
"<input type=\"checkbox\" name=\"$j\">"."<br>";
}
?>
<p align="left"><input type="submit"
name="delete" value="delete"></p>
Any and all help would be greatly appreciated.
Thanks,