homepage Welcome to WebmasterWorld Guest from 54.227.20.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
updating global variables
how to cary new variables to other pages
whatson

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4496097 posted 4:46 am on Sep 17, 2012 (gmt 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.

 

omoutop

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4496097 posted 7:40 am on Sep 17, 2012 (gmt 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]

jadebox

10+ Year Member



 
Msg#: 4496097 posted 10:03 pm on Sep 17, 2012 (gmt 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

whatson

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4496097 posted 7:40 pm on Sep 18, 2012 (gmt 0)

Oh right, thanks Roger, that makes sense.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved