无法将会话变量执行到下一页.


Not able to carry out the session variable to next page..!

我正在尝试将php文件中分配的会话变量携带到html文件中,但没有显示任何内容。。我已经尝试了很多方法来分配它并将会话变量携带到我的html页面,但无法做到这一点。请帮助我解决这个问题。。如果我做错了,请原谅。。!!

php

         <?php
                session_start();
                require_once 'DB_Functions.php';
                $db = new DB_Functions();
                // json response array
                $response = array("error" => false);
                if (!empty($_POST['salutation']) && !empty($_POST['fname']) && !empty($_POST['lname']) && !empty($_POST['dob']) && !empty($_POST['mobile']) && !empty($_POST['country']) && !empty($_POST['state']) && !empty($_POST['city']) && !empty($_POST['pin'])){
                        /*
                        if required include seperate validation
                        for some fields which require validation
                        */
                        // receiving the post params
                        $salutation = ($_POST['salutation']);
                        $fname = trim($_POST['fname']);
                        $lname = trim($_POST['lname']);
                        $dob = trim($_POST['dob']);
                       /* $email = trim($_POST['email']);
                        $password = $_POST['password'];*/
                        $mobile = trim($_POST['mobile']);
                        $country = trim($_POST['country']);
                        $state = trim($_POST['state']);
                        $city = trim($_POST['city']);
                        $pin = trim($_POST['pin']);
                        /*
                        validation process
                        starts from here
                        */
                        // validate your email address
                       /* if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
                                //validate your password
                                if(strlen($password) >= 6){*/
                                        //validate your mobile
                                        //$mobile="/^[1-9]*$/";
                                        if(strlen($mobile) == 10){
                                                 //Check for valid email address
                                                 /*if ($db->isUserExisted($email)) {
                                                                        // user already existed
                                                                        $response["error"] = true;
                                                                        $response["error_msg"] = "User already existed with " . $email;
                                                                        echo json_encode($response);
                                                                }*/
                                                                if($db->isMobileNumberExisted($mobile)) {
                                                                                //user already existed
                                                                                $response["error"] = true;
                                                                                $response["error_msg"] = "user already existed with" . $mobile;
                                                                                echo json_encode($response);
                                                                }else{  
                                                                        // create a new user
                                                                        $user = $db->storeUser($salutation, $fname, $lname, $dob, $mobile, $country, $state, $city, $pin);
                                                                        if ($user) {
                                                                                // user stored successfully
                                                                                $response["error"] = false;
/*here is the session variable
to be carried to next page
*/
                                                                                $_SESSION["user"]["vault_no"] = $user["vault_no"];
                                                                                echo json_encode($response);
                                                                        } else {
                                                                                // user failed to store
                                                                                $response["error"] = true;
                                                                                $response["error_msg"] = "Unknown error occurred in registration!";
                                                                                echo json_encode($response);
                                                                        }
                                                                }
                                        }else{
                                                //invalid mobile number
                                                $response["error"] = true;
                                                $response["error_msg"] = "PLEASE ENTER VALID MOBILE NUMBER!";
                                                echo json_encode($response);
                                        }
                             /*   }else{
                                        //min of 6-charecters
                                        $response["error"] = true;
                                        $response["error_msg"] = "PASSWORD MUST BE OF MINIMUM 6-CHARACTERS!";
                                        echo json_encode($response);
                                }
                        }else{
                                // invalid email address
                                $response["error"] = true;
                                $response["error_msg"] = "invalid email address";
                                echo json_encode($response);
                        }*/
                }else{
                        //missing the required fields
                        $response["error"] = true;
                        $response["error_msg"] = "Please fill all the required parameters!";
                        echo json_encode($response);
                }
        ?> 

html

    <div>
                        <?php
                        session_start();
                        echo "your vault number is" . "-" . $_SESSION["user"]["vault_no"];
                        ?>
                        </div>
                        <div>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <ul>
                        <h2 style="text-center"><li>Above is your 15 digit vault no, please do not share/Disclose to anyone.</li></h2>
                        <h2 style="text-center"><li>Please use this 15 digit no to modify your Vault or SignIn in to Miisky.</li></h2>
                        </ul>
                        </div>
<?php session_start(); ?> 

把这行写在页面的第一行

另一件事php没有在html页面中运行必须extantion php

<?php
session_start();
?>

需要在每一页的开头,在此之前没有任何内容。