Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending HUGE number of variables to another PHP file

Status
Not open for further replies.

djtizzlemaster

Programmer
Mar 5, 2008
17
US
For a while I was using the GET function, like so:

Code:
<a href="index.php?var1=$var1&var2=$var2">

The problem is that now I have a HUGE amount of variables, and somewhere - my guess is in browsers - there seems to be a limit on the length of a URL, because the variables toward the end of the URL are not getting sent.

Is there a better way to send the variables? It would be great if PHP had some kind of built-in function that could just send all the variables in a file to another file, something like this:

Code:
<a href="index.php?allvariables">

I know there's also the POST method, but I am not using a form on the page from which I'm sending the variables.
 
Think about why you are sending so many variables in the URL? Could you perhaps be better served by using session instead?

What do those variables you are sending contain?


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
That's a good point.. it might be a lot easier to just keep it in the same file.

I'm working on an order form. The variables contain user-submitted data.

The form is located on one file. Let's call it:

1. order.php. Then, when they click submit, they are sent to:

2. order_verify.php, where all of the data is displayed back to them so they can make sure it is correct. If it's correct and they click submit, they are taken to:

3. order_complete.php, which stores the order form on the server and emails a copy to myself, and thanks the user.

I don't know much about sessions. I am reading up on them now.
 
I think sessions will make it easier on you. Now although what you are doing can all be done in a single file its o.k to do it in 3.


sessions will store the information you want until the browser is closed or the session dies.

Code:
session_start();
$_SESSION['formvalue1']=$_POST['formvalue1'];

Then you can just use the $_SESSION super global in your subsequent pages to read the information.

Code:
session_start();
echo $_SESSION['formfield1'];

You can modify them, and you can delete them. You can also check for there presence so you can re-populate the form if any changes need to be made.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top