-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreateMonthlyTransaction.php
More file actions
43 lines (35 loc) · 1014 Bytes
/
createMonthlyTransaction.php
File metadata and controls
43 lines (35 loc) · 1014 Bytes
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
<?php include('./includes/conn.php');
$idu = $_POST['idu'];
$desc = $_POST['desc'];
$amount = $_POST['amount'];
$time = date("Y-m-d");
$return = 0;
$one = 1;
$mysqli = con_start();
$smtp = $mysqli->prepare("INSERT INTO Transaction (id_user, type, amount, monthly, created, description)
VALUES(?,?,?,?,?,?)");
$smtp->bind_param("iiiiss",$one ,$one, $amount,$one, $time, $desc);
$smtp->execute();
if (!$smtp->error) {
$return = 1;
}
else {
$return = 0;
}
$smtp->close();
$id_trans = 0;
if ($return == 1 ) {
// Id de tanda que se acaba de insertar
$mysqli = con_start();
$smtp = $mysqli->prepare("SELECT id_trans FROM Transaction ORDER BY id_trans DESC LIMIT 1");
$smtp->execute();
$smtp->store_result();
$smtp->bind_result($id_tand);
while ($smtp->fetch()) {
$id_trans = $id_tand;
}
$smtp->free_result();
$smtp->close();
}
echo $id_trans;
?>