Re: Passing var from one page to itself

From: Date: Thu, 25 Dec 2008 08:55:47 +0000
Subject: Re: Passing var from one page to itself
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-285067@lists.php.net to get a copy of this message
Hi there, Thanks so much everyone I really appreciate the help! I have it working now using hidden tags from each page to the next. www.adslgeek.com/troubleshooter Merry Christmas! Cheers Aslan tedd wrote:
At 4:10 PM +1300 12/21/08, Aslan wrote:
Hey there, I have a problem where I have a simple -script that I am wanting to pass back to itself three times 1) Symptoms - > 2) Troubleshooting questions 3) Answer to problem -snip- I have it currently all on one page, but it isn't quite what I was after .. Any help would be appreciated!
Hi Aslan: Keeping it all on one page (one script) is fine -- no problems with that. Here's the technique I use. $step = isset($__POST ['step']) ? $__POST ['step'] :1; if($step == 1) { // do the first page stuff (Symptoms) // with a POST form that has an <input type="hidden" name="step" value="1"> } if($step == 2) { // do the second page stuff ( Troubleshooting questions) // with a POST form that has an <input type="hidden" name="step" value="2"> } if($step == 3) { // do the third page stuff (Answer to problem) // with a POST form that has an <input type="hidden" name="step" value="3"> } If you want to pass variables between pages (trips from client to the server nad back again), you have four options, namely: 1) writing/reading a file; 2) writing/reading a database entry; 3) passing via a POST/GET; 4) or using SESSIONS. For most things, I prefer using POST/GET and/or SESSIONS. Try this format: $var1 = isset($_POST['var1']) ? $_POST['var1'] : null; $var2 = isset($_SESSION['var2']) ? $_SESSION['var2'] : null; That's the way I pass data between client and server. However, what you are describing sounds a bit like this: http://webbytedd.com/b/exam/ With this example, I'm not passing anything to the server -- everything is kept client-side and is quick. If interested, all the code is there. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com


« previous php.general (#285067) next »