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?
-
1@MohammadAreebSiddiqui You need to stop telling people to "check your answer". Scrolling down the page will allow them to do that anyway...Bojangles– Bojangles2013年07月05日 16:05:04 +00:00Commented Jul 5, 2013 at 16:05
-
@Bojangles , OK! Next time I will take care of it!Mohammad Areeb Siddiqui– Mohammad Areeb Siddiqui2013年07月05日 16:05:37 +00:00Commented Jul 5, 2013 at 16:05
1 Answer 1
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.