-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_transaction.php
77 lines (66 loc) · 2.03 KB
/
new_transaction.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
<?php include("database_connection.php"); ?>
<!DOCTYPE html>
<html>
<head>
<title>Budget App</title>
<link rel="stylesheet" type="text/css" href="new_transaction.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<div class="transactionsimage">
<h3><a>New Transaction</a></h3>
<form method="POST">
<strong type="amount" >Amount of money:</strong>
<input type="Number" name="money" step="0.01"><br><br>
<strong type="category">Category:</strong>
<select name="category">
<?php
$qeury_c="SELECT * FROM `categories` ORDER BY `idCategory` ASC";//butun cateqoriyalar
$ccategory=$con_db->query($qeury_c);
while($conc=$ccategory->fetch_assoc())
{
extract($conc);
echo "<option value='$idCategory'>$category</option>";
}
?>
</select><br><br>
<strong type="payment">Payment method:</strong>
<select name="method">
<?php
$qeury_p="SELECT * FROM `payments`";//butun payment
$payment=$con_db->query($qeury_p);
while($conc=$payment->fetch_assoc())
{
extract($conc);
echo "<option value='$idPayment'>$paymentMethod</option>";
}
?>
<select>
<strong type="date">Date:</strong><br>
<input id="date" type='date' name="date"><br><br>
<input type="submit" name="add" value="Add">
</form>
<?php
if(isset($_POST['add']))
{
$amount=$con_db->real_escape_string($_POST['money']);
$category=$con_db->real_escape_string($_POST['category']);
$method=$con_db->real_escape_string($_POST['method']);
$date=$con_db->real_escape_string($_POST['date']);
if($amount!='' && $date!='')
{
//add edir
$query="INSERT INTO `transactions` (`transactionAmount`, `transactionDate`, `idCategory`, `idPayment`) VALUES ('$amount', '$date', '$category', '$method')";
$con_db->query($query);
header('Location: transactions.php');
exit;
}
else
{
echo "Give Valid Data";
}
}
?>
</div>
</body>
</html>