Q:

how to use $_POST to post a php variable

I have a php variable "echo $id". Now I want to use the $_POST method to post the variable. I just want to know how to do this for a variable because $_POST[$id] does not work? I want the $id to be posted from the form into another page.
Below is my function where the $id is in:
function id_generator(){ 

          $id = ""; 
          $a = array( "A" , "B"); 

      for( $i = 0 ; $i < 3 ; $i++ ){ $r = rand( 0 , 25 );
       $id .= $a[ $r ]; 

   }

   return $id;
}

Below is the form:
         <form action="QandATable.php" method="post" id="sessionForm">
         <p><strong>1: Your Session ID: </strong><?php echo $id; ?></p>
</form>

Thanks

A:

You need to put the id into a form input field.  For example, to put it in a hidden input:
<form action="QandATable.php" method="post" id="sessionForm">
     <p><strong>1: Your Session ID: </strong><?php echo $id; ?></p>
     <input type='hidden' name='id' value='<?php echo $id; ?>' />
</form>

Then after the user clicks a submit button (which you will also need to add to the form), in QandATable.php you can just go
$id = $_POST["id"]

to get the id.

