-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathinvestp2p.php
More file actions
executable file
·52 lines (51 loc) · 1.73 KB
/
Copy pathinvestp2p.php
File metadata and controls
executable file
·52 lines (51 loc) · 1.73 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
<?php
include('config.php');
session_start();
$amount = $_POST['amount'];
$useruid = $_SESSION['user_data']['uid'];
$borrowuid = $_POST['borrowuid'];
$file = 'count.txt';
//get the number from the file
$uniq = file_get_contents($file);
//add +1
$uid = $uniq + 1;
$transuid = $uid + 1;
// add that new value to text file again for next use
file_put_contents($file, $transuid);
$row = mysqli_query($con, "SELECT * FROM wallet WHERE useruid='$useruid' ");
$row1 = mysqli_fetch_array("$row");
$balance = $row1['balance'];
if ($amount <= $balance) {
$qry5 = mysqli_query($con, "INSERT INTO transaction (useruid, amount, type, transuid, balance) VALUES ('$useruid', '$amt', 'credit', '$transuid', '$balance') ");
$balance -= $amount;
$qry6 = mysqli_query($con, "UPDATE wallet SET balance=$balance WHERE useruid='$useruid' ");
$qry = mysqli_query($con, "INSERT INTO invest (amount, useruid, borrowuid, investuid) VALUES ('$amount', '$useruid', '$borrowuid', '$uid') ") or die(mysqli_error($con));
$sql = mysqli_query($con, "SELECT * FROM borrow WHERE borrowuid='$borrowuid' ") or die(mysqli_error($con));
$sql1 = mysqli_fetch_array($sql);
$sql2 = $sql1['collect'];
$collect = $sql2 + $amount;
$qry1 = mysqli_query($con, "UPDATE borrow SET collect='$collect' WHERE borrowuid='$borrowuid' ") or die(mysqli_error($con));
if ($qry) {
?>
<script>
alert("Investment Successful.");
window.location.href = "index.php";
</script>
<?php
} else {
?>
<script>
alert("Investment Unsuccessful.");
window.location.href = "P2P_lending_lender.php";
</script>
<?php
}
} else {
?>
<script>
alert("Balance Low. Please Add Money!");
window.location.href = "dashboard.php";
</script>
<?php
}
?>