2

I'm trying to send an array to another page, such that when I get the array on the next page, only the array shows up and not the values. I then want to extract the values individually. I'm using the following code below. While this code works, on the redirect page, it returns 0=555928038&1=1694191&2=359564591&3=33280807&4=918458113 in the url. I don't want to see these values in the url. I want to see just the array and then I want to extract the values. What can I do to change this header redirect?

header('Location: twittercurlusershow.php?' . http_build_query($arrayoffollowers));
user2600095
  • 93
  • 1
  • 1
  • 9
  • 1
    since you are sending values through the URL, the values will be sent as GET which means they WILL show up in the URL. If you want to send values but not show them in the url, you can try setting values in the $_SESSION array. – Maximus2012 Jul 22 '13 at 04:11
  • 1
    This question needs a lot more research from OP to get a more specific question. It would seem there is a lack of understanding on how PHP works here. – rgin Jul 22 '13 at 04:11
  • @rgin I agree, a bit more clarity would be helpful here. – Maximus2012 Jul 22 '13 at 04:12
  • If you can extract the values in the next page, do your mind if the url is with `0=555928038&1=1694191&2=359564591&3=33280807&4=918458113`? – srain Jul 22 '13 at 04:17
  • The OP needs to understand the difference between GET and Post methods. – Brent Friar Jul 22 '13 at 04:17
  • @srain Yes, on some requests the url is going to go up to a hundred or much more. I just want to send it all as an array tand then get the array and then extract the 100 values. – user2600095 Jul 22 '13 at 05:55
  • Yes. @Maximus2012 is right. I updated my answer, there are 2 solutions, the one using $_SESSION is better, I paste some sample code in my answer, hope that would be helpful. – srain Jul 22 '13 at 06:47
  • @BrentFriar You could explain it to him? – Toby Allen Jul 22 '13 at 07:15
  • GET vs POST - http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get. That said, Oswald has the most correct answer. The array needs to be stored somewhere - where you put it is a matter of preference. $_SESSION seems like the easiest to me, but it's not uncommon to store session info in a database. – Brent Friar Jul 22 '13 at 17:34

2 Answers2

4

Store the array somewhere else (database, filesystem, session) along with a unique identifier. Attach the identifier to the URL. On the target page, restore the array from the identifier.

Alternatively, serialize and base64-encode the array, add it to the url as a request variable and on the target page, base64-decode and unserialize it. This is only feasible for small arrays because the maximum length of URLs a Browser can handle might be as low as 2083 bytes.

Oswald
  • 29,474
  • 3
  • 39
  • 67
1

You could use the $_SESSION variable to store the array on your original page and then call it up from twittercurlusershow.php.

Here is a tutorial on using $_SESSION.

Marko Kudjerski
  • 328
  • 2
  • 4