如何将所选选项传递到另一个页面

while I'm working with a Select Tag, nothing is displayed as can not be seen in the second page using $_SESSION variables. Someone helps me: I'm so confused: My first page:

  <?php
    session_start();
    if(isset($_SESSION['a'])){
        echo $_SESSION['a'];
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="test2.php">
      <label for="df"></label>
      <input type="text" name="df" id="df" />
      <select name="a">
      <option value="12" />12

      <option value="13"/>13

      </select>
      <input type="submit" value="send" />
    </form>
    <?php
    if(isset($_post)){
        if(isset($_POST['a'])){
    $_SESSION['a']= $_POST['a'];
    }
    }
    ?>
    </body>
    </html>

My second Page:

 <?php
    session_start();
    $r12=13;
    if(isset($_SESSION['a'])){
        echo $r12;
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>

    aaa
    <?php

    if(isset($_SESSION['a'])){
        echo $_SESSION['a'];
    }
    ?>
    </body>
    </html>

In your isset($_post), this should be isset($_POST)

<input type="submit" value="send" name="submit"/>

and

    if(isset($_POST['submit'])){

You are posting to test2.php, so only test2.php will receive the $_POST, not the first page!

If you call var_dump($_POST) on the second page, you should see the variables being sent. But $_POST will be empty when the form is displayed on the first page (i.e. before the form is submitted).

This will work: Just set the $_POST['a'] as a session and you can use it also at your other page.

<?php
    session_start();
    if(isset($_POST['submit'])){
        echo $_POST['a'];
        }
    else{
    ?>
<head>
    <title>Untitled Document</title>
</head>
<body>
    <form name="form1" method="post" action="index.php">
    <input type="text" name="df" id="df" />
        <select name="a">
            <option value="12" >12</option>
            <option value="13">13</option>
        </select>
    <input type="submit" value="send" name='submit' />
    </form>
    <?php
    }
    ?>
</body>
</html>

This is another way and Your first page should be something like this..

<?php
session_start();

if(isset($_SESSION['a'])){
   echo $_SESSION['a'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Untitled Document</title>
 </head>
 <body>
   <form id="form1" name="form1" method="post">
      <label for="df"></label>
        <input type="text" name="df" id="df" />
      <select name="a">
         <option value="12" />12
         <option value="13"/>13
        </select>
      <input type="submit" value="send" name="submit"/>
   </form>
<?php
if(isset($_POST['submit'])){
   if(isset($_POST['a'])){
      $_SESSION['a']= $_POST['a'];
        $url = 'test2.php'; // Define the URL:      
        header("Location: $url");
        exit(); // Quit the script.         
    }
}
?>
 </body>
</html>

Try this

if(isset($_POST) && !empty($_POST)){
 echo 'your selected option : '.$_POST['a'];
}