I am working on a web app that allows user to edit specific HTML & CSS elements.
For example, the user can specify the label of an anchor tag and where it links to, or specify the background color of the page using a form.
To create the initial file, i was thinking of using some kind of templating engine, where i can replace the value of a specific tag, but im not to sure on how to retrieve the existing values from a file that was created before. The workaround i can think of is using regex to search through the entire file and get the values that matches some certain pattern, but is there any easier way to do this?
update:
here is an example:
<a href="<?=$link?>"><?=$link_label?></a>
i want to be able to replace those links, and save the result in a file, and later on, i want to be able to retrieve the values that replaced these variables/
CSS is cascading. So you can allow the user to define their own CSS which is then included after the default CSS is. However, this is not safe- phishing, clickjacking, etc. The better would be that you define the attributes they can define (thus filter and validate it), store it in a database table (or XML/JSON file), query the table, generate CSS from result and include it after the default CSS.
In regards to HTML specific items; PHP is dynamic; you can store the user’s preferences in a database table (like MySQL) and query for these upon generating the page. I wouldn’t go about creating individual user specific files, it would defeat the purpose of PHP.