I'm using SKETCHWARE for framework make send BUTTON, but that's not the problem.
The problem is, how to send DATA with POST METHOD? HERE my HTML also PHP in one file.
<html>
<form action="index.php" method="POST">
<input type="hidden" name="data">
</form>
</html>
<?php
if (isset($_POST["data"]))
{
$data=$_POST["data"];
appendData("./database.txt",$data);//CONSIDER THIS FUNCTION IS APPENDING DATA with first parameter is file location and second parameter is content.
}
else {
echo("NoT SET");
}
?>
And this is the syntax (block code) in sketchware. Im just using first syntax because i dont know the that second and third function maybe you guys understand how it work and maybe can solve my problem.
before i use POST method, i was using with GET method with data input in URL, due to GET method limited to 1024character so i decide to use POST method with url, the problem is, it didnt send data like GET method.
GET is a type of a HTTP request where the parameter are stored in the url itself, whilst POST requests stores the data inside the request parameter, and it's format can be changed by using the Content-Type
HTTP header.
To put a data in the body, Create a Map. In that map, you can put whatever data you're sending, this case, is "data"="SENDED"
Use [[Map: ] put key ["data"] value ["SENDED"]]
to add the data to the map
Use the [[RequestNetwork: ] set params [Map: ] to request type [REQUEST_PARAM]]
block to place that map you created as the request body for the post request
Final Code:
variables:
- payload -> Map
Components:
- rn -> RequestNetwork
Code:
[Map: put key ["data"] value ["SENDED"]]
[[RequestNetwork: rn] set params [Map: payload] to request type [REQUEST_PARAM]]
[[RequestNetwork: codes] start network request to method [GET] to url ["https://example.com"] with tag []]