开发者

Simpletest PHP scriptable browser... how to test submit a form that has [ ] in the form name (basically in array format)?

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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜