-
Notifications
You must be signed in to change notification settings - Fork 0
/
invest.php
142 lines (106 loc) · 5.68 KB
/
invest.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
session_start();
require('./db_conn.php');
$email = $_SESSION['LOGGED_IN_EMAIL'];
$phone = $_SESSION['LOGGED_IN_PHONE'];
$userName = $_SESSION['LOGGED_IN_USERNAME'];
$statusinvest = 'processing';
function sanitize_input($data)
{
// Sanitize the data to prevent XSS attacks
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8'); // Use ENT_QUOTES to handle both single and double quotes
return $data;
}
$acount = "SELECT * FROM balance_account_users_profitedge WHERE Email_Address = ? AND User_Name = ?";
$acount_stmt = $mysqli->prepare($acount);
$acount_stmt->bind_param('ss', $email, $userName);
$acount_stmt->execute();
$acount_stmt_result = $acount_stmt->get_result();
$row_accbalance = $acount_stmt_result->fetch_assoc();
$AccountBalance = $row_accbalance['Balance_Available'];
if (isset($_POST['investGoldNow'])) {
$status = '';
$dateInvested = '';
$DateToEnd = '';
$amount = sanitize_input($_POST['gold_amount']);
$package = sanitize_input($_POST['gold_package']);
$selectDays = sanitize_input($_POST['gold_selectDays']);
$accumulative = sanitize_input($_POST['gold_accumulative']);
if ($AccountBalance >= $amount) {
$currentDateTime = date('Y-m-d H:i:s');
$endDate = date('Y-m-d H:i:s', strtotime($currentDateTime . ' + ' . $selectDays . ' days'));
$Total_Amount_To_Earn = intval($amount + $accumulative);
// Get the current date and time
// Calculate the end date by adding the selected number of days to the start date
// Insert the investment details into the database
$insertGoldInvestment = "INSERT INTO investments(Email_Address,User_Name,Phone_No,Amount,Days,Accumulative_Amount,Total_Amount_To_Earn,Package,End_Date,Status) VALUES(?,?,?,?,?,?,?,?,?,?);";
$invested = "INSERT INTO invested_amount(Email_Address,Phone_No,Amount,Date_invested) VALUES(?,?,?,?);";
$stmt88 = $mysqli->prepare($invested);
$stmt88->bind_param('siis', $email, $phone, $amount, $currentDateTime);
$stmt88->execute();
$stmt = $mysqli->prepare($insertGoldInvestment);
$stmt->bind_param('ssiiiiisss', $email, $userName, $phone, $amount, $selectDays, $accumulative, $Total_Amount_To_Earn, $package, $endDate,$statusinvest);
$stmt->execute();
echo "Congratulations! Gold Investment Success.";
} else {
echo "Insufficient funds in your Wallet!";
}
}
if (isset($_POST['investSilver'])) {
$status = '';
$dateInvested = '';
$DateToEnd = '';
$amount = sanitize_input($_POST['silver_amount']);
$package = sanitize_input($_POST['silver_package']);
$selectDays = sanitize_input($_POST['silver_selectDays']);
$accumulative = sanitize_input($_POST['silver_accumulative']);
if ($AccountBalance >= $amount) {
$currentDateTime = date('Y-m-d H:i:s');
$endDate = date('Y-m-d H:i:s', strtotime($currentDateTime . ' + ' . $selectDays . ' days'));
$Total_Amount_To_Earn = intval($amount + $accumulative);
// Get the current date and time
// Calculate the end date by adding the selected number of days to the start date
// Insert the investment details into the database
$invested = "INSERT INTO invested_amount(Email_Address,Phone_No,Amount,Date_invested) VALUES(?,?,?,?);";
$stmt88 = $mysqli->prepare($invested);
$stmt88->bind_param('siis', $email, $phone, $amount, $currentDateTime);
$stmt88->execute();
$insertsilverInvestment = "INSERT INTO investments(Email_Address,User_Name,Phone_No,Amount,Days,Accumulative_Amount,Total_Amount_To_Earn,Package,End_Date,Status) VALUES(?,?,?,?,?,?,?,?,?,?);";
$stmt = $mysqli->prepare($insertsilverInvestment);
$stmt->bind_param('ssiiiiisss', $email, $userName, $phone, $amount, $selectDays, $accumulative, $Total_Amount_To_Earn, $package, $endDate,$statusinvest);
$stmt->execute();
echo "Congratulations! Silver Investment Success.";
} else {
echo "Insufficient Funds in your Wallet!";
}
}
if (isset($_POST['investBronze'])) {
$status = '';
$dateInvested = '';
$DateToEnd = '';
$amount = sanitize_input($_POST['bronze_amount']);
$package = sanitize_input($_POST['bronze_package']);
$selectDays = sanitize_input($_POST['bronze_selectDays']);
$accumulative = sanitize_input($_POST['bronze_accumulative']);
if ($AccountBalance >= $amount) {
$currentDateTime = date('Y-m-d H:i:s');
$endDate = date('Y-m-d H:i:s', strtotime($currentDateTime . ' + ' . $selectDays . ' days'));
$Total_Amount_To_Earn = intval($amount + $accumulative);
// Get the current date and time
// Calculate the end date by adding the selected number of days to the start date
// Insert the investment details into the database
$invested = "INSERT INTO invested_amount(Email_Address,Phone_No,Amount,Date_invested) VALUES(?,?,?,?);";
$stmt88 = $mysqli->prepare($invested);
$stmt88->bind_param('siis', $email, $phone, $amount, $currentDateTime);
$stmt88->execute();
$insertBronzeInvestment = "INSERT INTO investments(Email_Address,User_Name,Phone_No,Amount,Days,Accumulative_Amount,Total_Amount_To_Earn,Package,End_Date,Status) VALUES(?,?,?,?,?,?,?,?,?,?);";
$stmt = $mysqli->prepare($insertBronzeInvestment);
$stmt->bind_param('ssiiiiisss', $email, $userName, $phone, $amount, $selectDays, $accumulative, $Total_Amount_To_Earn, $package, $endDate,$statusinvest);
$stmt->execute();
echo "Congratulations! Bronze Investment Success.";
} else {
echo "Insufficient Funds in Your Wallet!";
}
}