Welcome to WebmasterWorld Guest from 54.163.49.19

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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 21, 2002
posts: 1541
votes: 0


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 Sept 17, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 0


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 Sept 17, 2012 (gmt 0)

Junior Member

10+ Year Member

joined:June 24, 2004
posts:145
votes: 0


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 Sept 18, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 21, 2002
posts: 1541
votes: 0


Oh right, thanks Roger, that makes sense.