0

Okay so. I'm planning a minimal pastebin, for personal use. What I want is the URL to be:

http://xmpl.com/#paste/xY78r # 5 last chars being randomly generated

Thing is, I do not know how to get the last 5 characters. I would know how to get them if the URL was

http://xmpl.com/#paste?x=xY78r

, by simply using:

$x = $_GET['x'];

So question: Can I make the URL like: http://xmpl.com/#paste/xY78r and get the last five characters similar to the $_GET example above (to make a MySQL request for that character combination), without creating a folder on my server called xY78r?

Horribly explained, sorry, I tried. Not looking for a ready solution, just a nudge in the right direction.

Mo Mononoke
  • 175
  • 1
  • 11
  • no. `#` are not sent to the server. you'd need JS to intercept the click, parse the `#` out of the url, and convert it into a regular `script.php?x=xY78r` url – Marc B Sep 20 '16 at 21:36
  • @MarcB Alright, thanks Marc. I might just have to do this the correct way – Mo Mononoke Sep 20 '16 at 21:37
  • 1
    You could use a RewriteRule in your .htaccess and then just use $_GET in PHP as you were planning to – Ryan O'Connor Sep 20 '16 at 21:40
  • I wouldn't use random characters since then the only way to see if it exists or not is to do multiple DB queries until you find one that is not taken yet. I would instead recommend http://hashids.org/php/ – Mike Sep 20 '16 at 21:41
  • Possible duplicate of [Get fragment (value after hash '#') from a URL in php](http://stackoverflow.com/questions/2317508/get-fragment-value-after-hash-from-a-url-in-php) – Mike Sep 20 '16 at 21:50

0 Answers0