Simple PHP editor of text files

前端 未结 8 1518
名媛妹妹
名媛妹妹 2020-12-08 11:04

I have developed a site for a client and he wants to be able to edit a small part of the main page in a backend type of solution. So as a solution, I want to add a very basi

8条回答
  •  粉色の甜心
    2020-12-08 11:23

    First thing to do is capture the information, the simplest way to do this would be the use of a HTML Form with a TEXTAREA:

    On 'save.php' (or wherever) you can easily see the information sent from the form:

    
    

    To actually create a file, take a look at the fopen/fwrite commands in PHP, another simplistic example:

    
    

    WARNING: This is an extremely simplistic answer! You will perhaps want to protect your form and your file, or do some different things.... All the above will do is write EXACTLY what was posted in the form to a file. If you want to specify different filenames, overwrite, append, check for bad content/spam etc then you'll need to do more work.

    If you have an editor that is publicly accessible and publishes content to a web page then spam protection is a DEFINITE requirement or you will come to regret it!

    If you aren't interested in learning PHP then you should think about getting a professional developer to take care of any coding work for you!

提交回复
热议问题