Im using file_get_contents()
and the source is a url. Im also using ajax to insert html into the page.
The page when loaded:
<div>
<!-- Html goes here when the insert button is pressed -->
<input type="button" onclick="insertHtml()" value="insert"/>
<input type="button" onclick="saveThisPage()" value="save"/>
</div>
And when html is added dynamically with ajax:
<div>
<!-- Html goes here when the insert button is pressed -->
<div>Some text here...</div>
<div>Some text here...</div>
<div>Some text here...</div>
<input type="button" onclick="insertHtml()" value="insert"/>
<input type="button" onclick="saveThisPage()" value="save"/>
</div>
Now I want to save what file_get_contents()
returns and store the data into the mysql database.
I press the "save" button and a query is sent to a php file to read the page (url source) ...except what is saved is the content when loaded WITHOUT the new data i.e
<div>Some text here...</div>
What do I do? What function(s) do I use?
It's still very difficult to understand what you are trying to do. But basing my answer on this comment:
@coosal: I forgot to add the "save" button in my question. But the process 1.Page Loads, 2.I press "insert and data is added and 3.I press "save" and page is saved. php is called AFTER ajax loads the data
You can do that. Simply implement a save button on the HTML page which triggers another AJAX request to a PHP script which then saves the completed page:
<button onClick="$.post('save.php', {content:$('body').html()})">
Then simply receive the complete html body via:
file_put_contents("/tmp/saved.html", $_POST["content"]); // or mysql_*