Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $server = "dbxxxxxxxx.db.1and1.com";
- $dbname = "dbxxxxx";
- $dbusername = "dboxxxxxx";
- $dbpassword = "xxxxxxxx";
- header('Content-Type: application/json');
- try {
- $pdo = new PDO("mysql:host={$server};dbname=test;charset=utf8", $dbusername, $dbpassword);
- } catch (PDOException $e) {
- error_log($e->getMessage());
- die(json_encode(["query" => 1])); // fails
- }
- if (isset($_GET['wewn'], $_GET['piec'], $_GET['zew'], $_GET['humid'], $_GET['jasno'])) {
- $stmt = $pdo->prepare("INSERT INTO sensor (value,value2,value3,value4,value5) VALUES (:wewn,:piec,:zew,:humid,:jasno);");
- $stmt->execute([
- ':wewn' => $_GET['wewn'],
- ':piec' => $_GET['piec'],
- ':zew' => $_GET['zew'],
- ':humid' => $_GET['humid'],
- ':jasno' => $_GET['jasno']
- ]);
- echo json_encode(["query" => 0]); // ok
- }
- print_r($_GET);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement