-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_data.php
More file actions
59 lines (41 loc) · 1.16 KB
/
insert_data.php
File metadata and controls
59 lines (41 loc) · 1.16 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* Project: Smart Water Tank
* Created by: Jitesh Saini
*/
error_reporting(-1);
date_default_timezone_set("Africa/Kampala");
//----------database access----------------------------
include_once '../util/db_query.php';
include_once 'db_params_wt.php';
//-----------------------------------------------------
echo"Water level Logging<br>";
$val=$_GET["level"];
$passcode=$_GET["passcode"];
if ($passcode!="xyz"){
echo"passcode does not match<br>";
exit();
}
//$val="10";
insert_in_db($val);
function insert_in_db($val){
echo"val=$val<br>";
$connection=create_db_connection();
$t=time();
$date_time= date('Y-m-d H:i:s', $t);
echo "date_time=$date_time<br>";
$sql="INSERT INTO `level_log`(`level`, `timestamp`, `date_time`)
VALUES ('$val','$t', '$date_time')";
$result = get_results($connection,$sql);
if ( !$result ) {
die(mysql_error()."\n".$sql);
echo" !!!<br> ";
//return 0;
}
if ( $result ) {
echo" successfully inserted<br> ";
//return 1;
}
close_db_connection($connection);
}
?>