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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.