1

I am working on a site that has to deal with reservation numbers and I need to pass variables to confirmation page. Currently when you arrive at confirmation.php the URL looks something like the below:

http://localhost/confirmation.php?reservation_id=1&proceed=no

These variables are sent via a link to this page from the index page. I need a way to either encrypt the $reservation_id OR rewrite my URL so it looks like this

http://localhost/confirmation.php

...but still have access to my variables. I have tried sessions and some encryption methods, but cant find anything that wont over complicate the page as I am trying to keep it as simple as possible. Forms with hidden fields is not an option, I am printing all the reservations in links with a loop from the database.

Thanks!

3
  • You want do something complicated, but you don't want to over-complicated the page? Commented Dec 21, 2013 at 0:46
  • Why do you need to encrypt these things? Commented Dec 21, 2013 at 0:46
  • Put them in a session. The values are only available server-side. The only thing that is sent to the browser is a reference to session. Commented Dec 21, 2013 at 0:46

2 Answers 2

1

Use session variables. Create a random session variable name, and assign the reservation information to it:

foreach ($reservations as $r) {
    $random = make_random_string(); // You need to write this function
    $_SESSION[$random] = $r;
    echo "<a href='reservation.php?id=$random'>...</a>";
}

Then reservation.php can look up $_SESSION[$_GET['id']] to get the reservation information.

Sign up to request clarification or add additional context in comments.

Comments

0

It sounds like you need to start a session and pass the data in there. Or, you could POST the data instead (Use a form). But the session is probably the better choice.

2 Comments

He said forms are not an option, it sounds like it's a table of links. Like on Expedia when it lists all your itineraries.
@Barmar I don't know if that was there and I didn't see it or if it was added in an edit. Either way, Sounds like sessions are the right choice.

Your Answer

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.