Jump to content

Inserting php into mysql


tkuan77

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.