Skip to content

Instantly share code, notes, and snippets.

@SmetDenis
Created April 19, 2023 08:12
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 SmetDenis/c0b9cde5d85f183e59d812429911b235 to your computer and use it in GitHub Desktop.
Save SmetDenis/c0b9cde5d85f183e59d812429911b235 to your computer and use it in GitHub Desktop.
<?php
$type = $_POST['type'];
$result = $_POST['data']['result'];
$output = "";
if ($type == 'file') {
$file = fopen('db.txt', 'a+');
fwrite($file, $result);
$output = "stored in file";
} elseif ($type == 'db') {
$db = new PDO('mysql:dbname=test;host=127.0.0.1', 'user', 'pass');
$db->exec("INSERT INTO storage(value) VALUES('{$result}');");
$output = "stored in db";
}
echo $output;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment