-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex1.php
40 lines (31 loc) · 940 Bytes
/
index1.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
<?php
require_once "router.php";
route('/', function () {
require __DIR__ . '/home.php';
});
route('/callback', function () {
$mpesares = json_encode(file_get_contents("php://input"));
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "m_pesa";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO mobile_payments (response) VALUES ($mpesares)";
$file = "./res.txt";
if ($conn->query($sql) === true) {
file_put_contents($file, $mpesares);
} else {
file_put_contents($file, "Error: " . $sql . "<br>" . $conn->error);
}
$conn->close();
});
route('/about', function () {
return "This is the about page";
});
$action = $_SERVER['REQUEST_URI'];
dispatch($action);