-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
67 lines (62 loc) · 2.23 KB
/
index.php
File metadata and controls
67 lines (62 loc) · 2.23 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
60
61
62
63
64
65
66
67
<?php
require 'connection.php';
if(isset($_POST['submit'])){
$transactionAmount=mysqli_real_escape_string($mysql, $_POST['amount']);
$transactionDate=mysqli_real_escape_string($mysql, $_POST['date']);
$idCategory=mysqli_real_escape_string($mysql, $_POST['cat']);
$idPayment=mysqli_real_escape_string($mysql, $_POST['pay']);
$query= "INSERT INTO transactions(transactionAmount,transactionDate,idCategory,idPayment) VALUES ('$transactionAmount','$transactionDate','$idCategory','$idPayment')" ;
$result = $mysql->query($query);
header("Location: addtransaction.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Adding</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/index2.css">
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
</head>
<body>
<div class="form-style-8">
<h2>ADD TRANSACTION</h2>
<form action="index.php" method="POST">
<input type="number" name="amount" placeholder="Amount please..." />
<input type="date" name="date"/>
<?php
require 'connection.php';
$query_ak='SELECT idCategory,category FROM categories';
$result = $mysql->query($query_ak);
?>
<select name="cat">
<?php
while ($r = $result->fetch_assoc()){
echo '<option value="'.$r['idCategory'].'">'.$r['category'].'</option>';
}
?>
<?php
$query_a='SELECT idPayment,paymentMethod FROM payments';
$resulr = $mysql->query($query_a);
?>
</select>
<select name="pay">
<?php
while ($m = $resulr->fetch_assoc()){
echo '<option value="'.$m['idPayment'].'">'.$m['paymentMethod'].'</option>';
}
?>
</select>
<input type="submit" name="submit" value="ADD" />
<a href="addtransaction.php">see table</a>
</form>
</div>
<script type="text/javascript">
//auto expand textarea
function adjust_textarea(h) {
h.style.height = "20px";
h.style.height = (h.scrollHeight)+"px";
}
</script>
</body>
</html>