Skip to content

Instantly share code, notes, and snippets.

@av1m
Last active October 5, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save av1m/7d8e9b3cafd85592d066b5e13e44a931 to your computer and use it in GitHub Desktop.
Save av1m/7d8e9b3cafd85592d066b5e13e44a931 to your computer and use it in GitHub Desktop.
Sheety.co
<?php
$sheet = "coaching";
$url = 'https://v2-api.sheety.co/1sddadce23170ca5d4718fd855qs8/testing/'.$sheet;
$data = array(
$sheet => array(
"name"=> htmlspecialchars($_POST["nom"]),
"mail"=> htmlspecialchars($_POST["mail"]),
));
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\nAuthorization: Bearer xHKXqsdsdsqGs3xhSk7R6784\r\n",
'method' => 'POST',
'content' => http_build_query($data)
));
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response === FALSE) { /* error */ }
$json_array = json_decode($response, true);
if (array_key_exists($sheet, $json_array)) {
echo "OK";
} else {
echo "ERROR";
}
?>
<head>
<title>Sheety</title>
<script src="https://code.jquery.com/jquery-latest.js"></script>
<script>
function submit_sheety(){
var key_name = $("#name").val();
var key_mail = $("#mail").val();
var key_submit = $("#submit").val();
$.post("form_post.php",{
name:key_name,
mail:key_mail,
submit:key_submit
},
function(data){
$("#json_response").html(data);
});
}
</script>
</head>
<body>
<center>
<h3>Sheety</h3>
<form>
<input type="text" name="name" id="name" placeholder="Enter your name ..." required>
<input type="mail" name="mail" id="mail" placeholder="Enter your mail ..." required>
<input type="button" value="Submit" onclick="submit_sheety()"/>
</form>
<br>-----------
<div id="json_response"></div>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment