Jump to content

A textarea that shows the HTML of another page?


zrweber

Recommended Posts

I'm sure this is easy, but I haven't messed with PHP in 2 years and need a huuuugee refresher. But I need something simple.

 

I need a textarea that would show the HTML of another page, and allow you to edit the HTML of that page and save it, thus updating that page.

 

Example:

textarea.php has a textarea that shows the source of index.php

When you edit and save the changes of the textarea on textarea.php it updates index.php

 

This is really simple I'm sure, I just need a refresher on how I'd go about making this! Thank you very much for your time! :)

i haven't done much of anything with editing files in php, but i assume you'd do something along the lines of fopen to open the php file, throw the contents into the text area, and then when you hit the submit button or whatever you would save the file and close it.  then the next time index.php is opened, it would have the updated contents

use file_get_contents to retrieve the file.  Might possibly need to use nl2br on it (I don't remember if textareas render the \n's or not),  create a form and just echo it out between the textarea tags.  Name the text area, wrap form tags around it.  When it is posted, grab it from post and save it to file with file_put_contents

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.