0

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?

asked Jul 5, 2013 at 15:55
2
  • 1
    @MohammadAreebSiddiqui You need to stop telling people to "check your answer". Scrolling down the page will allow them to do that anyway... Commented Jul 5, 2013 at 16:05
  • @Bojangles , OK! Next time I will take care of it! Commented Jul 5, 2013 at 16:05

1 Answer 1

2

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.

answered Jul 5, 2013 at 16:08
Sign up to request clarification or add additional context in comments.

3 Comments

Now I understood! +1 for telling me what the OP's asking! :)
@MohammadAreebSiddiqui No worries :)
The id string is made in javascript. How do i pass that id string over to the php part so i can match it to the database?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.