-1

I'm trying to develop a site which asks or a username and creates a dare for their friends through a unique URL with a random ID.

I succeeded in generating random IDs with PHP uniqid() function to append them in URL.

But I have no idea to make the generated URLs valid.

All I need to make the generated URLs valid when they are opened and display a welcome page with the username.

yivi
  • 42,438
  • 18
  • 116
  • 138
  • 1
    Hi, welcome to stackoverflow. Please refer to the [how-to-ask](https://stackoverflow.com/help/how-to-ask) section in order to create a complete and answerable question. – Nicolas Sep 06 '19 at 13:39

1 Answers1

-1

You can pass the ID in a query string of the URL, that would be easiest approach:

http://yoursite.com/?ID=1234

You can append query string (the part that starts with ?) to any URL and it will still load just as fine. If you need to add more parameters, use &. For example: ?ID=1234&name=Username. These parameters are then accessible from global $_GET variable, or you can filter it out of the input stream:

$id = $_GET["ID"]; // This variable contains the ID passed in URL query string
$id = filter_input(INPUT_GET, "ID"); // This will produce the same result
René Beneš
  • 448
  • 1
  • 13
  • 29