-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
79 lines (75 loc) · 1.46 KB
/
index.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$db = "xxx";
$tableName = "xxx";
$colls = array(
PASSKEY,
stationtype,
dateutc,
tempinf,
humidityin,
baromrelin,
baromabsin,
tempf,
humidity,
winddir,
windspeedmph,
windgustmph,
maxdailygust,
rainratein,
eventrainin,
hourlyrainin,
dailyrainin,
weeklyrainin,
monthlyrainin,
totalrainin,
solarradiation,
uv,
wh65batt,
wh26batt,
freq,
model
);
$model = array(
$_POST[PASSKEY],
$_POST[stationtype],
$_POST[dateutc],
$_POST[tempinf],
$_POST[humidityin],
$_POST[baromrelin],
$_POST[baromabsin],
$_POST[tempf],
$_POST[humidity],
$_POST[winddir],
$_POST[windspeedmph],
$_POST[windgustmph],
$_POST[maxdailygust],
$_POST[rainratein],
$_POST[eventrainin],
$_POST[hourlyrainin],
$_POST[dailyrainin],
$_POST[weeklyrainin],
$_POST[monthlyrainin],
$_POST[totalrainin],
$_POST[solarradiation],
$_POST[uv],
$_POST[wh65batt],
$_POST[wh26batt],
$_POST[freq],
$_POST[model]
);
try {
$conn = new PDO("mysql:host=$servername; dbname=$db", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);;
$collsStr = implode(",",$colls);
$valuesStr = implode("', '", $model);
$sql = "INSERT INTO $tableName (".$collsStr.") VALUES ('$valuesStr')";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}