Page 1 of 1

Sessions Problem!

Posted: Tue Feb 03, 2009 12:28 pm
by fionaom87
Hello i am doing sessions in a project and i have one of my variables working with it but for some reason my other one isnt heres my code.

Code: Select all

 
 
<label> Bow Windows </label>
<div id="box24"><input type="text" name="quantity[]" size="1"selected="selected"> <label> Quantity</label></div>
            
<div id="box25"><img src="FYP/img19.jpg" alt="Windows"/>
<label> Bay Windows </label>
</div>
<div id="box26"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
            
<div id="box27"><img src="FYP/img20.jpg" alt="Windows"/>
<label> Speciality Type Windows </label>
</div>
<div id="box28"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
            
<div id="box29"><img src="FYP/img21.jpg" alt="Windows"/>
<label value="windowtype[2]"> Vertical Slider Windows</label>
</div>
<div id="box30"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
              
<div id="box31"><img src="FYP/img22.jpg" alt="Windows"/>
<label> Casement Windows </label>
</div>
<div id="box32"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
            
<div id="box33"><img src="FYP/img23.jpg" alt="Windows"/>
<label> Tilt and Turn Windows </label>
</div>
<div id="box34"><input type="text" name="quantity[]" size="1" selected="selected"><label> Quantity</label></div>
            
            
            <div id="box38">
            <input type="submit" value="Continue to Customer Details"/>
            
            </div>
            
            
            [color=#404000]<INPUT TYPE="hidden" name="windowtype[0]" VALUE="Bow Windows">[/color]
            <INPUT TYPE="hidden" name="windowtype[1]" VALUE="Bay Windows">
            <INPUT TYPE="hidden" name="windowtype[2]" VALUE="Speciality Type Windows">
            <INPUT TYPE="hidden" name="windowtype[3]" VALUE="Vertical Slider Windows">
            <INPUT TYPE="hidden" name="windowtype[4]" VALUE="Casement Windows">
            <INPUT TYPE="hidden" name="windowtype[5]" VALUE="Tilt and Turn Windows">
            </div>
            </div>
           

Code: Select all

 <?php
  
$qt = $_POST['quantity'];
$wt = $_POST['windowtype'];
 
$_SESSION['windowtype'] = array();
$_SESSION['quantity'] = array();
 
$i = 0;
foreach($qt as $a)
{
 if($a[$i])
 {
   $_SESSION['windowtype'][$i] = $wt[$i];
   $_SESSION['quantity'][$i] = $a[i];
   $i ++;
  }
}
?>
 
// my following page
 


my quantity value is appearing all right but my windowtype only appears all the time "Bow Windows" even when it isnt.

much appreciated for any help given, i think its only a small problem.

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 12:42 pm
by Skoalbasher

Code: Select all

 
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Bow Windows">
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Bay Windows">
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Speciality Type Windows">
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Vertical Slider Windows">
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Casement Windows">
            <INPUT TYPE="hidden" name="windowtype[]" VALUE="Tilt and Turn Windows">
 
I know yesterday we were talking about this. Did you try it without the numbers in there?

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 12:49 pm
by fionaom87
yes my quantity is working perfect .

the windowtype is in the form of a label?
would that be a reason why it not transfering over as easy as quantity(it is an input box)

Thanks

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 1:40 pm
by fionaom87
<label> Bow Windows <input name="windowtype[]" selected="selected" type="text"> </label> // this one isnt working

<input type="text" name="quantity[]" size="1" selected="selected"> // this one is working.

i jst want the label and the quantity to transfer over.

Thanks
F

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:21 pm
by Skoalbasher
I don't know if it matters, but try putting the

<INPUT TYPE="hidden" name="windowtype[]" VALUE="Speciality Type Windows">

BEFORE the submit. I dunno if that matters, but try that.

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:31 pm
by fionaom87
i wonder if im referencing windowtype[] properly this is what i have now:


<label name="windowtype[]"> Tilt and Turn Windows </label>???? i wonder is this right?
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Tilt and Turn Windows">

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:39 pm
by Skoalbasher
fionaom87 wrote:i wonder if im referencing windowtype[] properly this is what i have now:


<label name="windowtype[]"> Tilt and Turn Windows </label>???? i wonder is this right?
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Tilt and Turn Windows">
I don't think you should have the name in the label like in the first one..

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:44 pm
by fionaom87
ya ive been trying to look up what to call it but not finding anything. :banghead:

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:46 pm
by Skoalbasher
Did you put the hidden fields in before the submit button?

I find it hard to believe I'm the only one on here that can even attempt this. Sorry nobody else is jumping in to help ya.

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 2:51 pm
by fionaom87
yep here it is now

strange thing quantity is working (input box) and i just want to drag the label associated with that quantity.

<INPUT TYPE="hidden" name="windowtype[]" VALUE="Bow Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Bay Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Speciality Type Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Vertical Slider Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Casement Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Tilt and Turn Windows">

<input type="submit" value="Continue to Customer Details"/>

and this is on my following page

Code: Select all

 
 
 
<?php
  
$qt = $_POST['quantity'];
$wt = $_POST['windowtype'];
 
$_SESSION['windowtype'] = array();
$_SESSION['quantity'] = array();
 
$i = 0;
foreach($qt as $a)
{
 if($a[$i])
 {
   $_SESSION['windowtype'][$i] = $wt[$i];
   $_SESSION['quantity'][$i] = $a[i];
   $i ++;
  }
}
?>
 
 
 
 
 

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 4:04 pm
by Skoalbasher
fionaom87 wrote:yep here it is now

strange thing quantity is working (input box) and i just want to drag the label associated with that quantity.

<INPUT TYPE="hidden" name="windowtype[]" VALUE="Bow Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Bay Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Speciality Type Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Vertical Slider Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Casement Windows">
<INPUT TYPE="hidden" name="windowtype[]" VALUE="Tilt and Turn Windows">

<input type="submit" value="Continue to Customer Details"/>

and this is on my following page

Code: Select all

 
 
 
<?php
  
$qt = $_POST['quantity'];
$wt = $_POST['windowtype'];
 
$_SESSION['windowtype'] = array();
$_SESSION['quantity'] = array();
 
$i = 0;
foreach($qt as $a)
{
 if($a[$i])
 {
   $_SESSION['windowtype'][$i] = $wt[$i];
   $_SESSION['quantity'][$i] = $a[i];
   $i ++;
  }
}
?>
 
Try changing the $_SESSION names to something else. I've used duplicate names before with posts and it's messed it up.

Code: Select all

 
$qt = $_POST['quantity'];
$wt = $_POST['windowtype'];
 
$_SESSION['window'] = array();  // HERE
$_SESSION['quant'] = array();   // AND HERE
 
$i = 0;
foreach($qt as $a)
{
 if($a[$i])
 {
   $_SESSION['window'][$i] = $wt[$i];  // AND HERE
   $_SESSION['quant'][$i] = $a[i];   // AND HERE
   $i ++;
  }
}
 

Re: Sessions Problem!

Posted: Tue Feb 03, 2009 5:28 pm
by andym01480
You have got

Code: Select all

session_start()
at the very top of the script after the <?php tag and before any output to browser?