forked from d-jokic/parkBAND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn.php
executable file
·100 lines (72 loc) · 2.05 KB
/
conn.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
class conn {
function conn(){
$serverName = "myo-server.database.windows.net";
$connectionOptions = array(
"Database" => "myo",
"Uid" => "ParkinBand",
"PWD" => "SDPD*007"
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $conn;
}
function checkAuth($request){
$username = $request['username'];
$pass = $request['pass'];
$conn = $this->conn();
$sql = "SELECT * FROM myo WHERE username='".$username."'";
$result = mysqli_query($conn, $sql);
$row = $result->fetch_assoc();
$db_pass = $row['pass'];
if($pass == $db_pass){
$res = array(
"success"=>true,
"verified"=> true,
"username"=> $row['username']
);
$conn->upload($request);
}
else
{
$res = array("success"=>false, "verified"=> false);
$conn->close();
}
}
function upload($request){
$conn = $this->conn();
$Gyro = $request['gyro'];
$EMG = $request['emg'];
$sql = "INSERT INTO myo SET Gyro='".$Gyro."', EMG='".$EMG."'";
echo $Gyro;
echo $EMG;
if ($conn->query($sql) === TRUE) {
echo "YEAH BOI";
} else {
echo "NOOO BOI: " . $conn->error;
}
$conn->close();
}
}//end class
$conn = new conn;
$fn = $_REQUEST['fn'];
if(isset($fn)){
if($fn == 'upload'){
$conn->checkAuth($_REQUEST);
}
}
?>