to start I consider myself in between beginner and intermediate when it comes to PHP. On my website, I have a textarea that the user can input web code in and when a button is pressed, it sends the code to the page and displays the output. Here is the link to the page: http://opensourcewebsite.host22.com/editpage.php. Another problem that I am running into is that I want whatever the user enters to stay on the page.
Here is what the code looks like so far:
<?php $source_code = $_POST['source-code'}; ?>
...
<editable_area>
<?php echo $source_code ?>
</editable_area>
...
<form action="" method="post">
input class="result" type="submit" name="submit" value="View Result">
<textarea id="source" class="edit_are" name="source-code"></textarea>
Currently, when a user inputs code containing an id/class/name/etc. that has quotes in it, it is like when you do:
echo "<div id="Name">"
It will add the \” and thus messing up the code. I need to find a way to store the code so that it will display correctly. If you try the web page, you will see my issue first hand.
When the code is submitted, the textarea grabs the source code of the web page through javascript. I have discovered that if you leave out the “” in the code, it works as expected. The problem is that when it grabs the source code, there is quotes in it so the code will display them in the textare. This means every time you make a change, you need to take out all of the quotes.
Thanks to webbiedave, I fixed the quote problem by using:
<?php echo stripslashes($source_code) ?>
Now I just need to figure out how to permanently store changes.
1 Answer