0

I'm building an admin panel for some website, and I want to add the option to publish a new page. I want to build some text editor that will allow the publisher add HTML/PHP code.

I tried to insert text into dababase table and than print that:

EOF;
echo "1";
echo <<<EOF

But the output is "EOF; echo "1"; echo <<<EOF"

How can I add PHP/HTML code into my database table?

3
  • 5
    It's usually a very bad idea to do things like that, especially if that comes from a user input, as it could easily affect your server. Commented Aug 30, 2011 at 17:04
  • Usually, yes, but I could see doing this in something like an Admin Control Panel, for example if you're making a custom CMS system. Commented Aug 30, 2011 at 17:07
  • In this case im building CMS system, and the website will be stored in the site-owner server, so the user in this case can affect only on his own server.. or am im swong? Thanks for the comments. Commented Aug 30, 2011 at 17:36

2 Answers 2

2

It's reversed, it should be

echo <<<EOF


echo "1";


EOF;
Sign up to request clarification or add additional context in comments.

Comments

1

You can add php/html to the database like a normal, text. After when you retrieve your PHP code, if you want to execute it, you must use eval function.

1 Comment

and don't forget that the storing code in the database is almost always a sign of very bad software design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.