forked from akhs722/microfinance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwithdraw2.php
85 lines (74 loc) · 1.53 KB
/
withdraw2.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
<?php
session_start();
include 'functions.php';
include 'session.php';
if(!isset($_POST['user']))
{
alert("Error...","7");
}
$acc = $_POST['user'];
$amount = $_POST['pass'];
$_SESSION['accno'] = $acc;
include 'bond.php';
if(!$con)
{
alert("Error! check whether server is on..","7");
}
$q = "select * from xyz where accno = '$acc'";
$result = mysqli_query($con,$q);
$n = mysqli_num_rows($result);
if($n==0)
{
alert("Account Number Not Registered","7");
}
else
{
$row = mysqli_fetch_array($result);
$min = $row['min'];
$bal = $row['balance'];
if($bal < $amount)
alert("Insufficient Funds","7");
else
{
$newbal = $bal - $amount;
if($min <= $newbal)
{
$flag=0;
}
else
{
$min = $newbal;
$p = "update xyz set min = '$min' where accno = '$acc'";
if(!mysqli_query($con,$p))
{
alert("Error 1...","7");
}
}
$p = "update xyz set balance = '$newbal' where accno = '$acc' ";
if(mysqli_query($con,$p))
{
date_default_timezone_set('Asia/Kolkata');
$d = date("y-m-d");
$user = $_SESSION['username'];
$t = date("H:i:s");
$p = "insert into mno(accno,date,time,debit,credit,endamont,medium) values ('$acc','$d','$t','$amount','0','$newbal','$user')";
$n = mysqli_query($con,$p);
if($n)
{
mysqli_close($con);
alert("Success your updated Balance is INR$newbal",4);
}
else
{
mysqli_close($con);
alert("Unsuccessful...","7");
}
}
else
{
mysqli_close($con);
alert("Unsuccessful...","7");
}
}
}
?>