View the code on his login page and the page on which he submits and the variable.
Copy codeThe Code is as follows:
<Form method = "post" action = "login. jsp">
<Table align = "center" width = "40%" style = "FONT-SIZE: 12px" border = "0" cellpadding = "0" cellspacing = "2">
<Tr>
<Td width = "30%" align = "right" bgcolor = "# 0073AA" style = "FONT-SIZE: 12px; color: # ffffff"> name: </td>
<Td width = "70%"> <input type = "text" size = "30" name = "username"> </td>
</Tr>
<Tr>
<Td width = "30%" align = "right" bgcolor = "# 0073AA" style = "FONT-SIZE: 12px; color: # ffffff"> password: </td>
<Td width = "70%"> <input type = "password" size = "32" name = "passwd"> </td>
</Tr>
<Tr>
<Td colspan = "2" align = "right">
<Input type = "submit" name = "submit" value = "Login">
<Input type = "button" name = "submit" value = "regest" onclick = "location. href = 'regest. jsp '">
</Td>
</Tr>
</Table>
</Form>
Obviously, if you want to log on, you need to post the username, passwd, and submit variables to login. jsp, and submit = Login
Use the following code:
Copy codeThe Code is as follows:
<? Php
$ PostData = "username = your_name & password = your_password & Submit = Login ";
$ Posturl = "http: //.../login. jsp ";
$ PostUrl = parse_url ($ posturl );
$ Host = $ postUrl [host]? $ PostUrl [host]: "";
$ Port = $ postUrl [port]? $ PostUrl [port]: 80;
$ Path = $ postUrl [path]? $ PostUrl [path]: "/";
$ Fsp = fsockopen ($ host, $ port, & $ errno, & $ errstr, 30 );
If (! $ Fsp ){
Print "\ nopen socket failed \ n ";
} Else {
Fwrite ($ fsp, "POST". $ path. "HTTP/1.1 \ r \ n ");
Fwrite ($ fsp, "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd. ms-excel, application/vnd. ms-powerpoint, application/msword, */* \ r \ n ");
Fwrite ($ fsp, "Accept-Language: zh-cn \ r \ n ");
Fwrite ($ fsp, "Content-Type: application/x-www-form-urlencoded \ r \ n ");
Fwrite ($ fsp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon) \ r \ n ");
Fwrite ($ fsp, "Host:". $ host. "\ r \ n ");
Fwrite ($ fsp, "Content-Length:". strlen ($ postData). "\ r \ n ");
Fwrite ($ fsp, $ postData );
$ Resp = "";
Do {
If (strlen ($ out = fread ($ fsp, 1024) = 0) break;
$ Resp. = $ out;
} While (true );
Echo "<br>". nl2br ($ resp );
Fclose ($ fsp );
}
?>