-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_counter.php
More file actions
42 lines (35 loc) · 1.31 KB
/
Copy pathsave_counter.php
File metadata and controls
42 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
error_reporting(1);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
include_once('db.php');
if (isset($_POST["counter"])) {
$statement = $connection->prepare("SELECT * FROM guest_count WHERE date = '".date('Y-m-d')."' ");
$statement->execute();
$guest_counter = $statement->fetch(PDO::FETCH_ASSOC);
if(empty($guest_counter)) {
$statement = $connection->prepare("
INSERT INTO guest_count (date, count )
VALUES (:date, :count)
");
$result = $statement->execute(
array(
':date' => date("Y-m-d"),
':count' => $_POST["counter"]
)
);
} else {
$statement = $connection->prepare(" UPDATE guest_count SET count = :count WHERE date = '" . date('Y-m-d'). "' ");
$result = $statement->execute(
array(
':count' => $_POST["counter"]
//':created_date' => date("Y-m-d H:i:s"),
)
);
}
if (!empty($result)) {
echo $_POST["counter"] ."Guest Added saved successfully.";
} else {
echo "Data not saved try again.";
}
}