Viewing Hidden Fields from Form1 to Form2?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmc
    New Member
    • Nov 2006
    • 9

    #1

    Viewing Hidden Fields from Form1 to Form2?

    hi

    I have set hiddens fields in form1 and now i am trying to view the hiddens fields in form2....I did

    if(isset($_POST['confirm'])){......

    echo "$name";

    But the problem is ...It only show one row..it does not show all the rows for e.g.

    name
    ----------
    tom[tom]
    jerry[jerry]

    [tom]<<hidden field

    when i echo $name it only shows tom....the name column is in while loop...
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    If the other input is in a different form, then it won't be submitted when the User submits the first form. To get the value of the other hidden input, you'd need to include it in the same form as the first input on the page.

    Comment

    • mmc
      New Member
      • Nov 2006
      • 9

      #3
      i am trying to echo "room_Type_brea k" field, the problem is it only prints twice of each room_Type. for e.g.

      cal.php

      room_type
      --------
      ensuite
      ensuite
      single
      single

      book.php : Output:

      single single

      it is not printing out ensuite...any idea?


      cal.php
      [php]
      if($qty !== '0'){
      $p=0;
      while($fday<$td ay){
      echo "<td>$room_Type <input type='text' name='room_Type _break' value='$room_Ty pe'></td>
      $p++;

      }echo "<input type='hidden' name='count' value='$p'>"; }

      [/php]
      book.php
      [php]
      for ($i = 0; $i <= $_POST['count']; $i++) {

      $room_Type_brea k = $_REQUEST['room_Type_brea k_'.$i.''];

      echo "$room_Type_bre ak";
      }[/php]

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Try changing the name of the input from "room_Type_brea k" to "room_Type_brea k[]". That way, PHP will save all the entries in a field with that name to an array.

        Comment

        • mmc
          New Member
          • Nov 2006
          • 9

          #5
          i am confused...can u show me how using the code i posted previous

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Originally posted by mmc
            i am confused...can u show me how using the code i posted previous

            [php]
            if($qty !== '0'){

            $p=0;

            while($fday<$td ay){

            echo "<td>$room_Type <input type='text' name='room_Type _break' value='$room_Ty pe'></td>

            $p++;



            } echo "<input type='hidden' name='count' value='$p'>"; }
            [/php]

            [php]
            if($qty !== '0') {
            $p=0;

            while($fday < $tday) { // -----------------------------------¬
            echo "<td>$room_Type <input type='text' name='room_Type _break[]' value='$room_Ty pe'></td>
            $p++;
            }

            echo "<input type='hidden' name='count' value='$p'>";
            }

            [/php]

            Note the name of the input above. When you go to process your input after the User submits the form, you would reference $_REQUEST['room_Type_brea k'][0], $_REQUEST['room_Type_brea k'][1], etc.

            Comment

            • mmc
              New Member
              • Nov 2006
              • 9

              #7
              thanks...i used foreach loop to extract the data

              Comment

              Working...