I have the following HTML form (including JavaScript) from an external website that I'm trying to automate login for.
<form name="autologin" method="POST" action="https://post.website.com"></form>
<script language="JavaScript">
document.autologin.submit();
</script>
with inputs
<input type="hidden" name="Z" value="0,0">
<input style="font-size: 11px;" type="submit" value="Logon">
How do I submit this form programmatically using PHP, if it the second input has a missing name?
My code so far:
$url = 'https://post.website.com';
$request = new HTTP_REQUEST2($url, HTTP_REQUEST2::METHOD_POST);
$mainPageRequest = array(
'Z' => '0,0',
'' => 'Logon' // <---- What goes here since it's missing a name?
);
$request->addPostParameter($mainPageRequest);
$request->send();
Inputs without names are not submitted at all. If submitting a form in the normal way (by clicking the button), only those inputs that have names will be transferred; the others are simply ignored.
You can test for yourself by putting some inputs, with and without names in a form and using method="get"
, so that the submitted data ends up visually in the location bar.
So the answer to the question "What goes here since it's missing a name?" is: nothing.
$mainPageRequest = array(
'Z' => '0,0'
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.