简体   繁体   中英

edit a file via php

I've look around, and not found anything yet. So I'm going to ask a question, sorry if this is 'nooby'

What I want to do is this: Have a page with a form on it, IE: Form.php
and I want to allow myself to edit another page, IE: index.php
Kind of like a really BASIC two page CMS, edit it on the form.php page, and then it saves on index.php doesn't overwrite, but saves it under the current post that's already there.

Sorry for the 'vague' question, however want to do this fast :P

Instead of editing HTML or PHP using a PHP file, you should make a database, store content in it that you want to be dynamic, and retrieve from the database when the PHP for the dynamic page executes. Go read about SQL :)

(reposting so it can be chosen as selected answer, if you want!)

You can do it the way Patashu said with a database but if your only going to be editing one page you can do it with http://php.net/manual/en/function.fopen.php .

On the Form.php have it open index.php using PHP then have a textarea field that echos out the index.php and then using the Fopen function save over index.php . Make sure you secure Form.php with a password or even using a database. It also depends what programming language you will have inside index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM