Welcome to WebmasterWorld Guest from 54.145.181.138

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

updating global variables

how to cary new variables to other pages

   
4:46 am on Sep 17, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



e.g. I fill in a form for an inquiry on a used car. Then all the other used car inquiry forms will contain the value that I used in the previous form.

How can you create the variables that will used again on another page.
7:40 am on Sep 17, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



assuming all of your pages are in the same domain, $_SESSION is one way to do what you want.
After submitting your form, you can assign $_POST data to $_SESSION
for example:
session_start();
$_SESSION['myVar'] = $_POST['myVar'];


session_start() must be always ontop of all your scripts if you're gonna use sessions.

Start reading about $_SESIONS here [php.net]
10:03 pm on Sep 17, 2012 (gmt 0)

10+ Year Member



In addition to using a session, other options are to pass values as hidden fields in the forms; store values in cookies, or store information on the server (for example, in a database).

-- Roger
7:40 pm on Sep 18, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh right, thanks Roger, that makes sense.