2017-03-09 25 views
0

我呼籲通過PHP出於某種原因,我的Java服務器的PHP發送GET請求而不是POST被髮送,而不是POST HTML的「PHP-> JSP

我已經檢查了以下鏈接,但它不」幫助。

1>HTML form acting as get instead of post

2>Form sends GET instead of POST

3>Form sends a GET instead of POST

HTML CODE

<html> 
<head> 
<meta charset="UTF-8"> 
<title>Cloud Computing</title> 

</head> 
<body> 
<form action="url.php"> 
<table border="0"> 
<tr> 
    <td>Input</td> 
    <td align="center"><input type="text" name="input" size="30" /></td> 
</tr> 
<tr> 
    <td colspan="2" align="center"><input type="submit" onclick="url.php?input" action="url.php?input" method="post"/></td> 
</tr> 

</table> 

<form action="url.php?input" method="post"></form> 
</body> 
</html> 

PHP代碼

<html> 
<head> 
<meta charset="UTF-8"> 
    <title>PHP Test</title> 
</head> 
<body> 
<font face="century gothic" size="20px"> 
    <center> </br></br> 
    <?php 
     echo "Query:"; 
     echo $_GET["input"]; 
     echo $_POST["input"]; 
     $input = $_GET["input"]; 
     //echo file_get_contents("http://localhost:8080/CloudComputingProj/Cloudpi"); 
     # WARNING : maybe you should provide your context in the URL : provide the same URL that you use in your browser for example 
     $url = "http://127.0.0.1:8080/CloudComputingProj/Cloudpi"; 

     $post_params_s = ["input"=>$input]; 
     //echo post_params_s; 
     $ch = curl_init ($url) ; 
     curl_setopt ($ch, CURLOPT_POST   , TRUE) ; 
     curl_setopt ($ch, CURLOPT_POSTFIELDS , $post_params_s) ; 
     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE) ;    // -- put it to FALSE, write directly in main output 
     curl_exec ($ch) ; 
     curl_close ($ch) ; 
?></center> 
</font> 

</body> 
</html> 

Webhost error image

Eclipse output for request.getMethod

請幫助!

回答

0

似乎宥有兩種形式,二是設置好的爲action="url.php?input"(一個GET PARAM sintax) 由於事實上,你必須輸入一個名爲input你應該刪除錯誤的價值觀

..... 
     <form action="url.php" method="post"> 
      <table border="0"> 
      <tr> 
       <td>Input</td> 
       <td align="center"><input type="text" name="input" size="30" /></td> 
      </tr> 
      <tr> 
       <td colspan="2" align="center"><input type="submit" onclick="url.php?input" action="url.php?input" method="post"/></td> 
      </tr> 

      </table> 

     </form> 
</body> 
+0

1>刪除最後

2>刪除從提交操作按鈕 3>試圖改變
0

得到了修復!

由於@scaisEdge

是問題(還檢查我的最後評論)

如果我們增加方法= 「郵報」 用行動= 「url.php」 腳本發送POST。

它始終發送一個GET,因爲我有沒有方法,並由於某種原因它默認發送GET。

希望它可以幫助其餘的!

相關問題