forked from dotmat/ATTHackDoorPiATL
/
SaveUserDetails.php.save
executable file
·32 lines (32 loc) · 1.6 KB
/
SaveUserDetails.php.save
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
<?php
// Save User Details will get the details from UI welcome page
// and generate our JSON feed that the python script will later
// read from when the door bell is saved.
// Grab the details from the POST Request
$User0Name = $_POST["User0Name"];
$User0PhoneNumber = $_POST["User0PhoneNumber"];
$User1Name = $_POST["User1Name"];
$User1PhoneNumber = $_POST["User1PhoneNumber"];
// Assemble the JSON Feed so that we can reference our users by the Python Script
$JSON = '{"User0":{"Name":"'.$User0Name.'", "Number":"'.$User0PhoneNumber.'"},"User1":{"Name":"'.$User1Name.'","Number":"'.$User1PhoneNumber.'"}}';
// save the JSON String to the Users.JSON file so that we can reference it later.
$UsersFile = fopen("/DoorPi/Users.JSON", "w") or die("Unable to open file!");
fwrite($UsersFile, $JSON);
fclose($myfile);
?>
<?php
// Save User Details will get the details from UI welcome page
// and generate our JSON feed that the python script will later
// read from when the door bell is saved.
// Grab the details from the POST Request
$User0Name = $_POST["User0Name"];
$User0PhoneNumber = $_POST["User0PhoneNumber"];
$User1Name = $_POST["User1Name"];
$User1PhoneNumber = $_POST["User1PhoneNumber"];
// Assemble the JSON Feed so that we can reference our users by the Python Script
$JSON = '{"User0":{"Name":"'.$User0Name.'", "Number":"'.$User0PhoneNumber.'"},"User1":{"Name":"'.$User1Name.'","Number":"'.$User1PhoneNumber.'"}}';
// save the JSON String to the Users.JSON file so that we can reference it later.
$UsersFile = fopen("/DoorPi/Users.JSON", "w") or die("Unable to open file!");
fwrite($UsersFile, $JSON);
fclose($myfile);
?>