-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtran_up.php
101 lines (63 loc) · 2.54 KB
/
tran_up.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
<?php
require_once "controllerUserData.php";
require "connection.php";
$email = $_SESSION['email'];
$password = $_SESSION['password'];
$balx_php = $_SESSION['bal_php'];
echo $balx_php;
if($email != false && $password != false){
$sql = "SELECT * FROM usertable WHERE email = '$email'";
$run_Sql = mysqli_query($con, $sql);
if($run_Sql){
$fetch_info = mysqli_fetch_assoc($run_Sql);
$status = $fetch_info['status'];
$code = $fetch_info['code'];
if($status == "verified"){
if($code != 0){
header('Location: reset-code.php');
}
}else{
header('Location: user-otp.php');
}
}
}else{
header('Location: login-user.php');
}
// $name = "";
// $cname = "";
// $bal_php = "";
$errors = array();
$sql = "SELECT * FROM usertable WHERE email = '$email'";
$run_Sql = mysqli_query($con, $sql);
$fetch_info = mysqli_fetch_assoc($run_Sql);
$balance = $fetch_info['bal_php'];
if(isset($_POST['send_money'])){
$email = mysqli_real_escape_string($con, $_POST['email']);
$bal_php = mysqli_real_escape_string($con, $_POST['balance_php']);
$email_check = "SELECT * FROM usertable WHERE email = '{$email}'";
$res = mysqli_query($con, $email_check);
// $row = mysqli_fetch_row($res);
$row = $res->fetch_row();
if(mysqli_num_rows($res) > 0){
$errors['email'] = "Email that you have entered is valid!";
}
$update_data = "UPDATE `usertable`
SET `bal_php`= " . $row[6] . " + {$_POST['balance_php']} WHERE email = '{$_POST['email']}'"; // after ito
$update_data_2 = "UPDATE `usertable`
SET `bal_php`= " . $fetch_info['bal_php'] . " - {$_POST['balance_php']} WHERE email = '{$_SESSION['email']}'"; // ito una
// $update_data = "UPDATE `usertable` SET `bal_php`= '".$fetch_info['bal_php']."' - {$_POST['balance_php']} WHERE email = '{$_POST['email']}'";
$data_check = mysqli_query($con, $update_data);
$data_check_2 = mysqli_query($con, $update_data_2);
// print_r($data_check);
if($data_check){
header('Location: tran_wallet.php');
//$errors['data-check error'] = "error while checking";
}else{
$errors['db-error'] = "Failed while inserting data into database!";
}
}
else{
$errors['submit-error'] = "error 2";
}
mysqli_close($con);
?>