-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvariableinput.php
More file actions
59 lines (56 loc) · 1.51 KB
/
Copy pathvariableinput.php
File metadata and controls
59 lines (56 loc) · 1.51 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
59
<?php
$servername = "aropawoz.mysql.db.internal";
$user = "aropawoz_tobilu";
$pw = "WTp5g3bsVA8HfC-*f3+N";
$name = "aropawoz_financialplanning";
//$servername = "localhost";
//$user = "root";
//$pw = "root";
//$name ="ef5_webproj";
try {
header("Access-Control-Allow-Origin: *");
$conn = new PDO("mysql:host=$servername;dbname=$name;charset=utf8", $user, $pw);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo "<p style='color:rgb(87, 119, 143)'>Connection failed. " . $e->getMessage()."</p>";
};
try{
$income = $_POST['income'];
$rent = $_POST['rent'];
$food = $_POST['food'];
$freetime = $_POST['freetime'];
$clothes = $_POST['clothes'];
$hygiene = $_POST['hygiene'];
$others = $_POST['others'];
$output=[];
if ($rent != NULL){
$output[] = $rent;
};
if ($food != NULL){
$output[] = $food;
};
if ($freetime != NULL){
$output[] = $freetime;
};
if ($clothes != NULL){
$output[] = $clothes;
};
if ($hygiene != NULL){
$output[] = $hygiene;
};
if ($others != NULL){
$output[] = $others;
};
$number = count($output);
$x =0;
$out = 0;
while($number > $x){
$out += $output[$x];
$x += 1;
};
if ($income != NULL && $out != NULL){
$incomeinput = $conn->prepare("INSERT INTO variable(input,output) VALUES('$income','$out')");
};
}catch(PDOException $e){
echo "connection failes " . $e->getMEssage();
}