dsjlqkbpn029473708 2010-07-04 05:51
浏览 25
已采纳

最简单的PHP脚本浏览器...如何测试提交表单名称中具有[]的表单(基本上是数组格式)?

I am using simpletest, the php scriptable browser and trying to test submit a form that is in array format so its like this:

<input id="password" name="session[password]" value="" type="password">

Other input names start with "session" so I have to give the full name of each but it doesn't seem to work when I do it like this in my PHP script:

$this->setField('session[password]', 'password');

I'm wondering if anyone knows of a way to do this properly, or can I set it to look at the input's id instead, since this is always unique, as far as I know, I don't even understand why they chose name rather than ID as the field to use for this...

Any advice is greatly appreciated.

  • 写回答

1条回答 默认 最新

  • dongtan5558 2010-07-04 07:18
    关注

    You get the value the user has submitted by looking at $_POST["session"]["password"] (assuming the form method was "post", not "get").

    You can test it with this simple script:

    <?php
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        echo "<pre>";
        var_dump($_POST);
        die();
    }
    ?>
    <form method="post">
    <input id="password" name="session[password]" value="" type="password">
    <input type="submit" />
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口