Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Text File Updating

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Text File Updating

Postby chemaster » Fri Oct 25, 2002 4:57 am

I would like to be able to load a file (summary.txt) into a textarea of a form, make changes, and save the changes to the file. I have everything working EXCEPT I must refresh the page after I hit submit to see the changes. The text file is OK but it reloads the previous text into textarea. Any suggestions?

<? $stuff = implode("",file("summary.txt"));?>

<form method=post>
<textarea name="mytext" cols="50" rows="20">
<?php echo (htmlspecialchars($stuff)); ?>
</textarea>
<br>
<input type=submit>
</form>

<?php
$file = "summary.txt";
$fp = fopen("$file","w");
fputs($fp, $_POST["mytext"]);
fclose($fp);
?>
chemaster
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri Oct 25, 2002 4:54 am

Re: Text File Updating

Postby mjr » Fri Oct 25, 2002 9:58 am

use such command sequence:

<?php
$file = "summary.txt";
$fp = fopen("$file","w");
fputs($fp, $_POST["mytext"]);
fclose($fp);
?>



<? $stuff = implode("",file("summary.txt"));?>

<form method=post>
<textarea name="mytext" cols="50" rows="20">
<?php echo (htmlspecialchars($stuff)); ?>
</textarea>
<br>
<input type=submit>
</form>
mjr
New php-forum User
New php-forum User
 
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.