Forum Moderators: coopster

Message Too Old, No Replies

How to create simple php web templates

         

JAB Creations

12:23 am on Dec 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to know how to setup a basic textfield like the one used to create these posts to edit files online.

I figure this is simple and easy but everything I download has so much crud loaded in to it that it becomes nothing more then a ghost hunt...

Can anyone help?

strider1551

2:39 am on Dec 13, 2004 (gmt 0)



So, if I understand, you want:

1. load file into a text area box
2. edit text
3. save text

(sounds like what your want from your post, but "php web templates" in the title has me a little lost)

1.
The text field is simple enough, just use a form and a textarea. To get the file in the box, I recommend file_get_contents(). Something like this should do:


<form method="POST" action="update.php">
<p><textarea name="file" cols=50 value="<?php file_get_contents("myfile.txt");?>"></textarea></p>
<p><input type="submit" name="submit" value="Submit"></p>
</form>

2.
Change whatever you want in the box.

3.
In the resulting script(update.php), use file_put_contents():


<?php
file_put_contents("myfile.txt", $_POST['file']);
?>

Hope it helps.

jatar_k

4:23 am on Dec 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld strider1551