variables lose scope (and contents) between cards (WML)

I am new to PHP and WML. I have a strange issue happening in the code at the bottom. My class object variable, retains property values throughout some card links, but loses it on one card. These are the details.
There are seven cards:

  1. Start.: This is the first card. It shows a link to the next card ‘info’.
  2. Info: This is the second card. On this card are 4 text boxes to enter info in; Date, Contract, House, Street.
    In this card there is php code that initializes the variable, cJob as a new clsJob object.
    This card links to the next card, ‘UpdateInfo’. This is done via the <go method=‘post’ href="#UpdateInfo> tag block. The values from the 4 textboxes are passed to this cards php code via tags.
  3. UpdateInfo: This cards php code takes the values ‘posted’ from $_POST[], and assigns them to properties in the object variable cJob. It then uses the cJob->DumpAll() method to print the assigned values. This is done for testing. (trying to track down my problem).
    The code seems to work as expected to this point. From this card there is a link to the next card, ‘AddNewItem’.
  4. AddNewItem: This card begins with php code that again dumps the info from cJob for the purpose of testing. This works fine, showing that the cJob object remains in scope and contents remain as expected.
    This cards wml presents a selection box from which I select the item ‘Windows’. (There is only one selectable item, as I try to track down my problem.). When the item is clicked on, the tag links to the next card, ‘Wins’.
    5.Wins: This card also begins with the same php code that dumps the contents of the object variable cJob. Once again this works fine, and the contents and I guess scope of this variable remain.
    This card presents a selection of 4 different kinds of windows. On selecting any kind of window the next card is linked, ‘Update’. This is done via an tag block. The selected window type is passed via tag.
    The problem happens here. On pressing the link, the card ‘SelAmt’ is called. The postfield value is retrieved fine but the object var cJob loses scope (I think).
  5. SelAmt: The same php code here dumps the contents of cJob. This shows no values, as though the variable went out of scope.

What is it about this particular card that bust my object cJob?

NOTE: All cards are on the same page. Windows XP. Testing using, Firefox wml addon, winwap, winwap smartphone emulator. WML is valid. I will post the definition for clsJob as a reply.
[php]

<?php // send wml headers header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
    . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";

//
include ‘clsJob.php’;

$FileString="File String";

function GetJobDate(){
    date_default_timezone_set ( "America/Edmonton" );
    return  date("Y M d");
}

?>
[/php]

<wml>
    <card id="Start" title="Jobs IV - Start">
        <p>
            <anchor>
                <go href="#Info" />
                    New Job
			</anchor>
		</p>
	</card>
    <card id="Info" title="Job Info">
        <p>
            <?php
                $cJob = new clsJob();
                $FS = "Date:<br /> \n";
                $FS .= "<input type= \"text\" name=\"date\" value=";
                $FS .= "\"" . GetJobDate() . "\" /><br />";
                print $FS;
			?>

 Contract:<br />
            <input type="text" name="contract" value="" /><br />


	 		House:<br />
			<input type="text" name="house" value="" /><br />

			Street:<br />
			<input type="text" name="street" value="" /><br />

			<anchor>
                <go method="post" href="#UpdateInfo">
                    <postfield name="date" value="$(date)" />
                    <postfield name="contract" value="$(contract)" />
                    <postfield name="house" value="$(house)" />
                    <postfield name="street" value="$(street)" />
                </go>
                Update Job Info
			</anchor>		  
			<br /><br /><br />
			<a href="#Start">Back</a>
        </p>			
    </card>
    <card id="UpdateInfo" title="Update Job Info">
        <p>
            <?php
                $FS="";
                $FS .= $cJob->AddItem("Date", $_POST["date"]);
                $FS .= $cJob->AddItem("Contract", $_POST["contract"]);
                $FS .= $cJob->AddItem("House", $_POST["house"]);
                $FS .= $cJob->AddItem("Street", $_POST["street"]);
                print $FS;
                print "<br />";
                $cJob->DumpAll();
            ?>
            <br /><br /><br />
					<anchor>
                <go href="#AddNewItem">
                </go>
						 Go to Item List
					</anchor>
        </p>
    </card>
    <card id="SelAmt" title="Select Amount">
        <p>
            <br />
            <?php
                print "SelAmt";
                $cJob->DumpAll();
    		?>
            <?php
                $sItem = $_POST["itemName"];
                print "Item Name: " . $sItem;
                print "<br />Current Amount: " . $cJob->GetItemAmt($sItem); 
                $FS = "<br />Additional Amount:<br /> \n";
                $FS .= "<input type= \"text\" name=\"amtItems\" format=\"3N\" value=";
                $FS .= "\"" . $cJob->GetItemAmt($sItem) . "\" /><br />";
                print $FS;
            ?>
            <anchor>
                <go method="post" href="#Update">
                    <?php
                        print "<setvar name=\"itemName\" value=\"" . $sItem . "\" />";
                    ?>
                    <postfield name="uName" value="$(itemName)" />						  		
                    <postfield name="uAmt" value="$(amtItems)" />
                </go>
                Update
            </anchor>
        </p>
	 </card>
    <card id="AddNewItem" title="Add Info Item">
        <p>
            <?php
                print "AddNewItem";
                $cJob->DumpAll();
            ?>
            <br />Select Item:<br />
            <select name="toc" title="Select Item">
                <option onpick="#Wins">Windows</option>
<!--                <option onpick="#Doors">Doors</option>
                <option onpick="#Base">Baseboards</option>
                <option onpick="#Lock">Lockout</option>
                <option onpick="#Misc">Misc</option> 
                <option onpick="#Show">View Job</option>
                <option onpick="#Save">Save Job</option> --> 
            </select>
        </p>
    </card>
    <card id="Wins" title="Add Window">
        <p>
            <?php
                print "Wins";
                $cJob->DumpAll();
            ?>
            Window Type:<br />
            <select name="sWins" title="Windows">
                <option value="windows">Foam</option>
                <option value="windowsNF">No Foam</option>
                <option value="Hwindows">High</option>
                <option value="HwindowsNF">High No Foam</option>
            </select>
       		<br />
    		<anchor>
                <go method="post" href="#SelAmt">
                    <postfield name="itemName" value="$(sWins)" /> 
                </go> 
                Add Window
            </anchor>
        </p>
    </card>
	 <card id="Update" title="Update">
        <p>
            <?php
                $uName = $_POST["uName"];
                print "xxx: " . $uName;
                $uAmt = $_POST["uAmt"];
                $FS= $cJob->AddItem($uName, $uAmt);
                print $FS;
            ?>
            <br /><br /><br />
            <anchor>
                <go href="#AddNewItem">
                </go>
                Back to Item List
            </anchor>
        </p>
    </card>
</wml>

This is class clsJob:
[php]<?php
class clsJob
{
public $cDate;
public $cHouse;
public $cStreet;
public $cContract;
public $cItem = Array();

		public function GetItemAmt($Name){
				 switch($Name){
				 case "Date":
				 case "Contract":
				 case "House":
				 case "Street":
				 default:
				 			if($cItem[$Name]!=""){
									return $cItem[$Name];
							}else{
									return 0;
							} //if 
				 } //switch			
		} //GetItemAmt

		public function DumpAll(){
				 print "<br />Date: " . $this->cDate;
				 print "<br />Contract: " . $this->cContract;
				 print "<br />House: " . $this->cHouse;
				 print "<br />Street: " . $this->cStreet;
				 
				 if(is_array($this->cItem)){					 
					 foreach($this->cItem as $Key => $Value){
 	 					 print "<br />" . $Key;
					 	 print "  " . $Value;
					 } //foreach
				 }else{
				 	 print "<br /> " . $this->cItem[0];
				 } //if	 
				 
		} //DumpAll

		public function AddItem($sName, $Value){
		 	switch($sName){
			case "Contract":
						$this->cContract = $Value;
						$FS = "<br />Contract: " . $this->cContract;
						break;
			case "Date":
						$this->cDate = $Value;
						$FS = "<br />Date: " . $this->cDate;
						break;
			case "House":
						$this->cHouse = $Value;
						$FS = "<br />House: " . $this->cHouse;
						break;
			case "Street":
						$this->cStreet = $Value;
						$FS = "<br />Street: " . $this->cStreet;
						break;
			default:
						$curVal = (float)$this->cItem[$sName];  
						$this->cItem[$sName]+=(float)$Value;
						
						$FS ="<br />Item Name: " . $sName;
						$FS .= "<br />Original Amount: " . $curVal;
						$FS .= "<br />Additional Amount: " . $Value; 
						$FS .= "<br />Current Amount: " . $this->cItem[$sName];
			 } //switch
      return $FS;
					 
		} //AddItem 

}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service