I would like to post HTML code to a PHP page and then display that HTML inline. Is that safe to do? Since it's a simple form could someone post a PHP instead of HTML? What code do I use to make sure no PHP is submitted to the server?
More details:
This is my PHP page,
<HTML>
<body>
<textarea id="html_textarea"></textarea>
<button type=submit>Preview</button>
PREVIEW
<?PHP
echo $_REQUEST['html_textarea'];
</PHP>
</body>
</HTML>
Example data:
<div>Hello world</div>
What I don't want to happen is someone post this data:
<?php
// something malicious or not safe for work
</php>
Does this make sense?
ANOTHER UPDATE:
Thanks for all the help. I need to give more details. I am writing an HTML editor online. So the developer can create and write their HTML pages and then I want to let them preview their HTML pages. They can write the body HTML and add a list of CSS and JS to include.
I could create an HTML page for them but I think it's not safe to create HTML pages on the server on the fly (or maybe it is?). I think I should let them post their HTML and CSS and JS to my PHP page on my server* and then I put it all together for them and display it. My thought was it would be only temporary. But according to the site on XSS it would be a non-persistent vulnerable. It maybe that I can only allow previewing only when the developer is logged in then.
*I say my server and then I get shivers. So that is why I ask the question here. What if I posted to their server (they would have to have a server). I would feel much safer but then the developer has to have their own server (maybe a good thing).