2017-03-26 72 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