PHP Session不会保存唯一值

时间:2015-12-18 11:32:06

标签: php

我想保存此按钮的name=""部分

<button type="submit" class="btn grey large" id="taxicompany" name="<? echo $rows['company']; ?>">select</button>

所以当我这样做时

<?php echo "".$_SESSION['POSTDATA']['taxicompany'].''; ?>

显示name=""

的值

但它不会显示?

2 个答案:

答案 0 :(得分:4)

为什么不给按钮一个值

<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="<? echo $rows['company']; ?>">select</button>

然后,当您提交表单并引用$ _POST ['taxicompany']时,您将获得值

http://www.w3schools.com/tags/att_button_value.asp

答案 1 :(得分:1)

试试这个:

<form method="post">
<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="your company name">select</button>
</form>

// PHP code
if(isset($_POST['taxicompany']))
{
    $_SESSION['POSTDATA']['taxicompany'] = $_POST['taxicompany'];
    echo $_SESSION['POSTDATA']['taxicompany']; //your company name
}