I am calling my java server via PHP and for some reason the PHP sends a GET request instead of POST
I have checked the following links but it doesn't help.
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 Code
<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>
Eclipse output for request.getMethod
Kindly Help !