2017-03-26 76 views
0

我想PHP值發送到CGI URL如何將PHP表單POST值發送到CGI url?

<form method="post" action="https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi/cgi-bin/outgoingfw.cgi" style="float:left"> 
        <input name="ACTION" value="disable" type="hidden"> 
        <input name="line" value="0" type="hidden"> 
       </form> 

這些值我想用PHP POST請求發送到URL

https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi

任何一個可以幫助我如何去做這個。

+0

您在操作屬性中有'cgi-bin/outgoingfw.cgi'兩次。您也可以查看[本教程](http://www.rebol.com/docs/cgi2.html)瞭解更多信息。 –

+0

查找捲曲:http://php.net/manual/en/book.curl.php –

回答

0

你缺少一個備查提交按鈕

<form action="https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi/cgi-bin/outgoingfw.cgi" method="POST"> 
     <input type="submit" value="Publish"> 
     <input name="ACTION" value="disable" type="hidden"> 
     <input name="line" value="0" type="hidden"> 
</form> 

http://www.comp.leeds.ac.uk/Perl/Cgi/textareas.html

0

只需添加一個 「提交」 按鈕,這一切都需要。

 <!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Title</title> 
</head> 
<body> 
<form method="post" action="https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi" style="float:left"> 
    <input name="ACTION" value="disable" type="hidden"> 
    <input name="line" value="0" type="hidden"> 

    <!-- submit button --> 
    <input type="submit" value="submit"/> 

</form> 
</body> 
</html> 
+0

但價值並不傳遞任何東西happing –

+0

我編輯我的答案顯示完整的代碼。這工作,我嘗試在我的服務器,它的工作原理。當然你只是發佈empy「行」變量。我沒有訪問你的「https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi」,所以它只是返回一個錯誤,但表單發佈 –

+0

順便說一句,你不應該使用JavaScript發佈表單除非你需要。當你不需要它的時候使用javascript是不好的代碼,它只會讓它變得更復雜,更慢,並且不會增加任何東西 –

0

如果您想自動發送。無需按下按鈕。否則,爲什麼你需要隱藏的領域?

<form method="post" action="https://192.168.10.1:10443/cgi-bin/outgoingfw.cgi/cgi-bin/outgoingfw.cgi" style="float:left"> 
     <input name="ACTION" value="disable" type="hidden"> 
     <input name="line" value="0" type="hidden"> 
    </form> 
    <script> 
     document.getElementsByTagName('form')[0].submit(); 
    </script> 
+0

但是值不會傳遞任何東西hacking –

+0

嘗試插入我的代碼並在瀏覽器中打開「網絡」,然後看到請求已發送 – gud3

+0

如果你想在頁面上得到答案,那麼你需要使用[ajax](http://api.jquery.com/jquery.ajax/) – gud3