Well you can store encoded / encrypted form of HTML. But that is not a correct way. And when you try to store whole web pages in database, It will increase the database size and decrease the performance. And also you will need to allow the safe html tags only.
And if you allow javascript and load the stored webpage content under your same domain like, https://yoursite.com/storedsite-id-or-name
There is a possibility, User can steel all the cookies of the domain, By using javascript.
If user insert PHP codes, There are no issues because php won't execute until you run the code. If you get the html from database and show as Plain Text, It won't execute.
But In my opinion.
You can store these lengthy html content in a file as encoded
or encrypted
form. And use a unique hash
as the filename. You can use your custom extension too.
7815696ecbf1c96e6894b779456d330e.sitedata
And prevent direct access. And store the site information in database.
Like,
------------------------------------------------------------------
row_id | user_id | site_name | site_source
------------------------------------------------------------------
1 | 34 | sample-site | 7815696ecbf1c96e6894b779456d330e
Then you can view the site,
https://yoursite.com/sample-site
When user request this URL, You need to get the site-name
from URL. And get the site source file
from database. Then read the file content and decode / decrypt
to the actual content. Then you can render the page with the content.