Jump to content

[SOLVED] File writing Help


Vivid Lust

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>

 

 

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.