使用会话将所选选项的值发布到第二页

时间:2014-12-10 19:37:43

标签: php html forms session post

我一直在尝试使用SESSIONS方法发布两个选定下拉菜单的值,但是似乎存在问题,因为提交时第二页仅显示PHP代码。以下是代码的相关摘要:

shop.php

<form action="processing.php" method="post"> <div class="item">
    <span class="caption">Essential Gray Suit<br />£459</span>
    <select name="size1" class="size" id="size1" onchange="showDiv(this)">
        <optgroup label="Size">
        <option value="0">SELECT SIZE</option>
        <option value="1">XS</option>
        <option value="2">S</option>
        <option value="3">M</option>
        <option value="4">L</option>
        <option value="5">XL</option>
    </select>

    <div id="quantity1" style="display: none;">
    <select name="quantity1" class="size"  onchange="showCart(this)">
        <optgroup label="Quantity">
        <option value="0">SELECT QUANTITY</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
    </select>
    </div>
<input type="submit" value="Submit" name="submit" id="submit">
</form>

processing.php

<?php
session_start();
if (isset($_POST['submit'])) { 
  $_SESSION['size1'] = $_POST['size1'];
} 


echo $_SESSION['size1'];

?>

0 个答案:

没有答案