Jump to content

How to delete lines from a txt file based on checkbox selection


anzacdan

Recommended Posts

Hey all need some help with the subject title.

 

Have a user text file with all information(Name, address, passwords, etc..) Need to be able to select the user based on Checkbox selection then hit delete button and all users checked will be removed from the txt file and thus removed from HTML page. Im using PHP to show contents of the txt file into my HTML page.

 

So far i have:

 

 

<?php

$file = fopen("user.txt","r");

 

echo '<table border="0" width="100%">

<tr>

<th>Select</th>

<th>Username</th>

<th>Password</th>

<th>FirstName</th>

<th>LastName</th>

<th>Email</th>

<th>Address</th>

</tr>

';

while(!feof($file)) {

$user = explode(":", fgets($file));

 

echo '<tr>

<td><input type="checkbox" name="chkDelete" id = "chkDelete" value="select" /></td>

<td>' . $user[0] . '</td>

<td>' . $user[1] . '</td>

<td>' . $user[2] . '</td>

<td>' . $user[3] . '</td>

<td>' . $user[4] . '</td>

<td>' . $user[5] . '</td>

</tr>';

 

echo '</table>';

fclose($file);

?>

 

Am unsure as to how i would go about doing this, help would be greatly appreciated!

 

Thanks in advanced,

 

Daniel.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.