Jump to content

Recommended Posts

I have these two codes:

 

<?php
$filename = "../includes/top.html";
$file = fopen( $filename, "r" );
$filesize = filesize($filename);
$text = fread( $file, $filesize ); 
fclose( $file ); 
?> 
Above the Uploader<br>
<form action=bodys.php method=POST><textarea name="top" id="textarea" cols="45" rows="5" value=<?php echo $text; ?>></textarea><Br>
Below the Uploader<br>
<textarea name="bott" id="textarea" cols="45" rows="5"></textarea><br>
<input type="Submit" value=Update>
</form>

 

<?php
$top = $_POST['top'];
$filename = "../includes/top.html";
$file = fopen( $filename, "w+" );
fwrite( $file, $top ); 
fclose( $file ); 
header('location: body.php');
?> 

 

There are two probablems, one problem is when opening the file in the text box there is an extra > at the end.

 

The second problem is when "updating" the file, it deletes a bit from the beginning such as the <h1>

 

Please help!!

 

Thanks loads in advanced.

 

Link to comment
https://forums.phpfreaks.com/topic/115604-solved-file-writing-help/
Share on other sites

<?php

$filename = "../includes/top.html";

$file = fopen( $filename, "r" );

$filesize = filesize($filename);

$text = fread( $file, $filesize );

fclose( $file );

?>

Above the Uploader<br>

<form action="bodys.php" method="post" enctype="application/x-www-form-urlencoded">

    <textarea name="top" id="textarea" cols="45" rows="5"><?php echo $text; /* see the html reference on textarea, value="" is not an attribute of textarea */ ?></textarea><Br>

Below the Uploader<br>

    <textarea name="bott" id="textarea" cols="45" rows="5"></textarea><br>

    <input type="submit" value="Update">

</form>

 

 

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.