這不是客戶端操作,它是服務器端操作。不需要「form2」。您想爲此使用curl。類似這樣的:
// Set up a connection to the target of form1 (this is the "action" attribute of form1)
$curl_connection = curl_init('http://hostname.com/form1.asp');
// Set up so options -- connection timout, store to string, follow redirects
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
// Set the post fields, this is just like a query string and contains the contents of form1 fields
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "field1=value1&field2=value2");
// Run the query and capture the results
$data = curl_exec($curl_connection);
curl_close($curl_connection);
// At this point $data should contain the ticket number
var_dump($data);
不幸的是,它必須是客戶端操作。 「form1」服務器不會接受任何不協商NTLM身份驗證的連接。所以我必須讓它看起來像在互聯網瀏覽器的用戶提交表單。上面的解決方案是一個很棒的解決方案,但是我試過了:(服務器響應「未授權」,我嘗試以明文形式發送密碼,但它也不喜歡這樣。 – 2011-01-27 06:05:57