I want to send some data to another server but I don't want user to view the data.
I tried submitting form but others still manage to see the data even it is hidden.
PS: The server only receives $_POST
.
Asked
Active
Viewed 76 times
-2
-
use forge.js to encrypt the data in base64 – Satya Sep 24 '18 at 03:42
-
1you could send from the server with curl() – Sep 24 '18 at 03:46
-
Did you use `method="post"` in your form tag? – hemnath mouli Sep 24 '18 at 07:15
-
How can a basic user see a POST data ? Check your form method – Bobby Axe Sep 24 '18 at 07:57
2 Answers
1
You use curl
for this purpose.
An example:
<?PHP
function POST($url,$data,$headers,$type)
{
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
if($type === 1)
{
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($data));
}
else
{
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$output = curl_exec ($ch);
$posturl = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
$cURLinfo = curl_getinfo($ch);
curl_close($ch);
return array(
"output" => $output,
"posturl" => $posturl,
"httpcode" => $httpCode,
"diagnostics" => $cURLinfo
);
}
?>
But most likely, this is a duplicate of How do I send a POST request with PHP?

maio290
- 6,440
- 1
- 21
- 38
-1
use forge.js to encrypt the data in base64 e.g.
jQuery.post('yourfile.php',
{uname: forge.util.encode64(jQuery('#uname').val()) ,
upass: forge.util.encode64(jQuery('#upass').val() )
},function(data)
{
console.log(data);
});
and then in PHP you can use
$user = base64_decode($_POST['uname']);
$passw = base64_decode($_POST['upass']);
to retrieve the data.

Satya
- 8,693
- 5
- 34
- 55
-
1
-
I believe what he meant was while submitting data via HTML the data needs to be encrypted, and proposed a solution based on this. If OP re-confirms he is asking to do it via PHP, I will delete the post happily – Satya Sep 24 '18 at 04:24
-
"but I don't want user to view the data" - and you use Javascript? base64 is not secure anyway. – maio290 Sep 24 '18 at 08:45