Reputation: 568
I want to make a save functionality like the one on jsfiddle. But i don't really know how to do it. So i have stored some data on a mysql database and used history.pushState
to put a key in the url bar:
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghijklmnopqrstuvwxyz";
var string_length = 5;
var num_chars = chars.length;
var result = '';
while(string_length--) {
result += chars[ Math.floor( Math.random() * num_chars ) ];
}
history.pushState('', '', result);
I am using jquery, ajax, php to insert data into the database. The "result" is stored as a ID in the database. How do i use that to get the right data from the database. How do i make that url shareable to others?
Upvotes: 0
Views: 94
Reputation: 26143
Give the URL with an ID in it, like this (for example)...
http://yoursite.com?pageid=1234
and then in PHP you can access it like this...
$pageid = $_GET["pageid"];
You can then use that value to get data from your MySQL database as required.
Upvotes: 2