1

I have an issue that I cannot display the selected value using session. Can I check that previously I have a created a dropdown list(Page1.php) and display my selected value on Page2.php using session then on page2.php I have another droplist list as below (page2.php) but I could not display the selected value on page3.php using session. I cant figure where it is wrong.

Page2.php:

<?php session_start(); ?>
<select name="amtoftable" size="1" class="StyleTextField" id="amtoftable" >
<p>
</p>
<?php if($_SESSION['svenue'] == 'Bliss'){ ?>
<option value="-1"> Select no.of tables</option>
<?php $dbtables = $_COOKIE["amtoftable"];
 if ($dbtables == "41")
 echo "option selected = 'true' value = '41'>41</option?>";
 else echo "<option value='41'>41</option>"; ?>


<?php $dbtables = $_COOKIE["amtoftable"];
 if ($dbtables == "42")
 echo "option selected = 'true' value = '42'>42</option?>";
 else echo "<option value='42'>42</option>"; ?>

  <?php
     if(isset($_POST['SubmitBooking'])){
      if($_POST['amtoftable'] == '41')
          $stable = '41';
      }
         else if($_POST['amtoftable'] == '42')  
         $stable = '42';
      }
            //save session
           $_SESSION["ctables"] = $_POST['amtoftable'];
          die("<script>location.href = 'Payment.php'</script>");
     }

page3.php

<?php session_start(); ?>

<label for="label-tables">No.of tables:  </label>`enter code here`

<?php echo  $_SESSION['amtoftable'];?>
1
  • hi i missed out this part <?php if(isset($_POST['SubmitBooking'])){ if($_POST['amtoftable'] == '41') $stable = '41'; } else if($_POST['amtoftable'] == '42') $stable = '42'; } //save session $_SESSION["ctables"] = $_POST['amtoftable']; die("<script>location.href = 'Payment.php'</script>"); } Commented Apr 23, 2015 at 15:37

2 Answers 2

1

One page2 you say $dbtables = $_COOKIE["amtoftable"];, but on page3 you are calling $_SESSION['amtoftable']. Also, where is $dbtables assigned?

Sign up to request clarification or add additional context in comments.

Comments

0

an option will be selected when you put this condition

  <option value="41"  <? if($value=='41') {echo "selected=selected" }?> </option

other wise it will not select the value in select option once check with this and let us know where your strucking behind will help

1 Comment

"<option value='41'>41<? echo "selected=selected" ?> </option> do you mean by the above?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.