Jump to content

How can I amend to a text file so that the text is added before a hyperlink?


APD1993

Recommended Posts

Hi,

 

I am writing several scripts and some are used to amend extra information to a text file. However, I added a hyperlink to the text file so that the user can go back to a page where they can add extra information. However, since I have done this every time I amend more text to the text file, the extra text appears below the hyperlink rather than above it, and I was wondering if there was a way around this.

 

My amend code is as follows:

 

<html>
<head>
<title>Amend File</title>
<link rel="stylesheet" type="text/css" a href="rcm/stylesheet.css">
</head>
<?php

if($_POST['append'] !=null)
{
$filename="C:/xampp/htdocs/rcm/denman2.txt";
$file=fopen($filename, "a");
$msg="<p>Updated Information: " .$_POST['append']. "</p><br>";
fputs ($file, $msg);
fclose($file);
}
?>
<body>
<h1>Do you want to append to a document?</h1>
Enter Updated Information:
<form action="amendfile2.php" method="post">
<input type="text" size="40" name="append"><br><br>
<input type="submit" value="Add updated information to report">
</form>
<form action="viewfile3.php" method="post">
<input type="submit" size="40" value="View Web Blog">
</form>
<form action="loginform.php" method="post">
<input type="submit" value="Click here to go to the Log In Screen">
</form>
</body></html>

 

And my text file is as follows:

<h1>Accident Report</h1>

<p>First Name: Andrew
Last Name: Denman
Age: 18
Complete Weeks Since Accident: 2<br>

<a href="amendfile2.php">Amend to this file</a>

 

Any help would be appreciated :D

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.