Created
April 19, 2023 08:12
-
-
Save SmetDenis/c0b9cde5d85f183e59d812429911b235 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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