Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:19:15+00:00 2026-05-30T07:19:15+00:00

comm.php <? $com = $req_user_info[‘comments’]; $name = $username; if($_POST) { $postdate = date(d M

  • 0

comm.php

<?
$com = $req_user_info['comments'];
$name = $username;

if($_POST) {
$postdate = date("d M y h:i A");
$content = $_POST['commentContent'];
$handle = fopen("$com","a");
fwrite($handle,"<b>" . $name . "</b>:<br>" . $content . "<br>" . $postdate . "<br>"); 
fclose($handle);}
?>

<html>
<body>
<form action = "" method = "POST">
Post a Comment<br><textarea rows="10" cols="30" name="commentContent"></textarea><br>
<input type="submit" value="Comment"><p>
Comments<p>
<? 
include($com);
?>
</body></html>

/*$req_user_info['comments']; = data.txt*/

data.txt

Alex: sometext 20 Feb 12 11:11 AM
Alex: sometext 20 Feb 12 11:38 AM

What I want to do is delete (or replace with nothing) name, content and postdate.

Example:

Alex: sometext 20 Feb 12 11:11 AM Delete

Alex: sometext 20 Feb 12 11:38 AM Delete

So after I click delete and refresh the page I want the line to be gone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:19:16+00:00Added an answer on May 30, 2026 at 7:19 am

    Instead of just including the file normally, you could use fgets to read line by line (http://www.php.net/manual/en/function.fgets.php). Store each line number as you iterate though, then on your delete link, pass the line number.

    <a href="page.php?delete=XXX">Delete</a>
    

    When you then want to delete, simple go through each line and rewrite the file, skipping the line that was given with the delete link variable $_GET[‘delete’]. Just make sure you’re counting as you write each new line so you know when to skip a line.

    Using the PHP example:

    <?php
        $counter = 0;
        $handle = @fopen("/tmp/inputfile.txt", "r");
        if ($handle) {
        while (($buffer = fgets($handle, 4096)) !== false) {
            $counter++;
            echo $buffer . '<a href="page.php?delete='.$counter.'">delete</a>';
        }
        if (!feof($handle)) {
            echo "Error: unexpected fgets() fail\n";
        }
        fclose($handle);
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code in inc/q/prof.php: <?php // Insert Comments into Database that user provides $comm =
I have an application that reads data from a com port using javax.comm. The
I need to be able to shorten my page from: mydomain.com/mixtape.php?mixid=(WHATEVER NUMBER) To: mydomain.com/m/(WHATEVER
I am interested in working for a web-design company. Actually, this one: http://z-comm.com/ And
My RewriteRule is: RewriteRule ^m/watch/([0-9]+)$ /m/watch.php?v=$1 [NC,L] When I try to go to http://www.example.com/m/watch/555
When I read the source of Codeigniter, I found a function located in file:system/codeigniter/comm.php
I found free source project to send sms using java comm: http://code.google.com/p/find-ur-pal/source/browse/src/?r=21 Function sending
DbParameter param = comm.CreateParameter(); param = comm.CreateParameter(); param.ParameterName = @StaffId; if (!string.IsNullOrEmpty(activity.StaffId)) param.Value =
I am using a program that talks to my COMM port, but I have
Is there a java library or framework (other than the javax.comm provided by Sun)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.