tkuan77 Posted August 11, 2010 Share Posted August 11, 2010 Hi, Does anyone have any idea how to insert an entire php or html pages into mysql once the page has being created with php? E.g. np1.php <form action="np2.php" method="post"> Name of New Page: <input type="text" name="newpage_name" /> <input type="submit" /> </form> np2.php <?php $newpage_name = $_POST[ 'newpage_name' ]; $newpage_initial = "Input Contents Here."; //echo $editor_data; $newpage_file = "test/" . $newpage_name . ".php"; $newpage_save = fopen($newpage_file, 'w'); fwrite($newpage_save, $newpage_initial); fclose($newpage_save); ?> I have managed to create a new file with php but I also want it when I click on the submit button, it will also auto save that new php file or html file into mysql. Regards Jas Quote Link to comment https://forums.phpfreaks.com/topic/210441-inserting-php-into-mysql/ Share on other sites More sharing options...
aeroswat Posted August 11, 2010 Share Posted August 11, 2010 I don't believe you can store the php after the page has been executed... Php is a server side scripting so you will never see php code once the page is done loading. If you want to do it before hand I'm sure you could just save it in a string, insert it into the database. Print out the string. Quote Link to comment https://forums.phpfreaks.com/topic/210441-inserting-php-into-mysql/#findComment-1098077 Share on other sites More sharing options...
tkuan77 Posted August 11, 2010 Author Share Posted August 11, 2010 Hi, so is there a way around it? Regards jas Quote Link to comment https://forums.phpfreaks.com/topic/210441-inserting-php-into-mysql/#findComment-1098227 Share on other sites More sharing options...
PFMaBiSmAd Posted August 11, 2010 Share Posted August 11, 2010 You can store anything (made up of data) you want in a database table, as long as it makes sense. Do you want to store the page name (URL) of the page or do you want store the actual source php code or HTML that makes up the page? Storing the actual source php code in a database table doesn't make a lot of sense unless you are making a php script site and you want to display the code instead of execute it. Quote Link to comment https://forums.phpfreaks.com/topic/210441-inserting-php-into-mysql/#findComment-1098249 Share on other sites More sharing options...
tkuan77 Posted August 12, 2010 Author Share Posted August 12, 2010 Hi, What I am trying to do is whenever the user created a new page it will be stored in the database and they can select it from a drop down list etc to view the page or edit the page or source code of the page with a text area editor such as ck editor or tinyMCE. Do note that it is for internal usage only. Do hope that there is a way to solve this problem. Regards Jas Quote Link to comment https://forums.phpfreaks.com/topic/210441-inserting-php-into-mysql/#findComment-1098377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.