传递两页PHP值

时间:2015-07-05 06:34:11

标签: php

试图刷新我对PHP的记忆并遇到了这个问题。我试图将值从一个页面传递到另一个页面。我一直在尝试会话变量,并调用了session_start()。即使在page ='string'上设置变量,也不会打印任何内容。我在这做错了什么?我试图从联系人页面到review.php页面获取星号和textarea的价值

   <!DOCTYPE html> 
    <html> 

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <title>Contact</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
        <link rel="stylesheet"  href="Icons/icon-pack-custom.css" />
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
        <style>
            [data-role=page]{height: 100% !important; position:relative !important;}
            [data-role=footer]{bottom:0; position:absolute !important; top: auto !important; width:100%;} 
            #banner img {
                width:100%;   
            }
            .ui-collapsible {
                width:130px;
            }



        </style>
    </head> 


    <body> 

    <!-- Start of first page: #one -->
    <div data-role="page" id="home" data-theme="b">

        <div data-role="header" >

            <h1>Forever Fitness</h1>



            <nav data-role="navbar" data-iconpos="left">

                <ul>
                    <li><a href="index.html" data-icon="home" class="ui-btn-active ui-state-persist">Home</a></li>
                    <li><a href="provinces.html" data-icon="shop" data-ajax="false">Products</a></li>
                    <li><a href="ContactUs.html" data-icon="phone">Contact Us</a></li>
                </ul>
            </nav>

        </div><!-- /header -->

        <div data-role="content" >

        </div><!-- /content -->
        <div data-role="controlgroup">
            <p>  

            <?php
        session_start();
        echo $_SESSION['ta'] = 'string';
        ?>

            </p>
                <a href="index.html" data-role="button">Home</a>
                <a href="ContactUs.html" data-role="button">Back</a>

            </div>

    </div><!-- /page one -->

下一页开始

  <?php
    session_start();
    $_SESSION['ta'] = 'string';
    ?>

<!DOCTYPE html> 
<html> 

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Citizenship Canada</title> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
    <link rel="stylesheet"  href="Icons/icon-pack-custom.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <style>
        [data-role=page]{height: 100% !important; position:relative !important;}
        [data-role=footer]{bottom:0; position:absolute !important; top: auto !important; width:100%;} 
        #banner img {
            width:100%;   
        }
        .ui-collapsible {

        }



    </style>
</head> 


<body> 

<!-- Start of first page: #one -->
<div data-role="page" id="home" data-theme="b">
    <div data-role="header" >
        <h1>Forever Fitness</h1>
        <nav data-role="navbar" data-iconpos="left">

            <ul>
                <li><a href="index.html" data-icon="home" >Home</a></li>
                <li><a href="provinces.html" data-icon="shop" >Products</a></li>
                <li><a href="ContactUs.html" data-icon="phone" data-ajax="false" class="ui-btn-active ui-state-persist">Contact Us</a></li>
            </ul>
        </nav>

    </div><!-- /header -->
    <div data-role="content">
     <div data-role="collapsible" data-collapsed-icon="phone" data-expanded-icon="phone">
            <h4>Contact By Phone</h4>
            <ul data-role="listview" data-inset="true">
                    <li>1-800-991-1929 Toll Free</li>   
            </ul>
        </div> 
     <div data-role="collapsible" data-collapsed-icon="phone" data-expanded-icon="phone">
            <h4>Contact By Email</h4>
            <ul data-role="listview" data-inset="true">
                    <li><a href="mailto:ggg99@gmail.com" data-role="button">Send an Email</a></li>

            </ul>
    </div> 

             <ul data-role="listview" data-inset="true">
                    <li><a href="#r">Write a Review</a></li>

            </ul>
    </div> 

    </div>
    <div data-role="page" id="r" data-theme="b">

    <div data-role="content" >  
        <h2 style="text-align:center;">Write a Review</h2>
        <form action="review.php" method="get">
            <label for="stars">Stars</label>
            <input type="range" name="stars" id="stars" value="5" min="0" max="5" data-highlight="true" />
            <div data-role="fieldcontain">
                <label for="textarea">Your Review</label>
                <textarea name="textarea" id="textarea"></textarea></br>
                <input type="submit"value="submit" data-theme="b">
            </div>
        </form>



    </div><!-- /content -->
    <div data-role="controlgroup">
            <a href="index.html" data-role="button">Home</a>
            <a href="ContactUs.html" data-role="button">Back</a>

        </div>
</div><!-- /page one -->
</html>

1 个答案:

答案 0 :(得分:1)

第一页 - 定义会话变量

<?php
session_start();
$_SESSION['ta'] = 'string';
?>

在第二页 - 显示会话变量

<?php
session_start();
echo $_SESSION['ta'];
?>