Jump to content

[SOLVED] Hidden form elements


snow

Recommended Posts

Hi can someone simply explain how I can use hidden form elements so I can keep variables for later on.

 

For example:

 

Web Page 1 (Has the forms) --> Web Page 2 (gets $_POST) --> Web Page 3 now has lost all the post data from page 2, how do I keep it so I can re-use it?

 

I'm new at php and any help would be appreciated, preferrably simple methods!

Thanks heaps in advance!

Link to comment
Share on other sites

use sessions

 

put:

session_start();

at the top of each page.

 

then you can pass variables from page to page in your code by assigning them to the session array.

 

page 1:

<?php
session_start();
$_SESSION['var1'] = "some data";
?>

 

page2 or 3 or 4 or whenver you want as long as the person keeps there browser open and comes back to your site:

<?php
session_start();
echo $_SESSION['var1'];
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.