Vivid Lust Posted July 19, 2008 Share Posted July 19, 2008 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 More sharing options...
ignace Posted July 19, 2008 Share Posted July 19, 2008 <?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> Link to comment https://forums.phpfreaks.com/topic/115604-solved-file-writing-help/#findComment-594277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.