-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer_add_action.php
147 lines (129 loc) · 4.28 KB
/
customer_add_action.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
143
144
145
146
147
<?php
include "validate_admin.php";
include "connect.php";
include "header.php";
include "user_navbar.php";
include "admin_sidebar.php";
include "session_timeout.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="action_style.css">
</head>
<?php
$fname = mysqli_real_escape_string($conn, $_POST["fname"]);
$lname = mysqli_real_escape_string($conn, $_POST["lname"]);
$gender = mysqli_real_escape_string($conn, $_POST["gender"]);
$dob = mysqli_real_escape_string($conn, $_POST["dob"]);
$aadhar = mysqli_real_escape_string($conn, $_POST["aadhar"]);
$email = mysqli_real_escape_string($conn, $_POST["email"]);
$phno = mysqli_real_escape_string($conn, $_POST["phno"]);
$address = mysqli_real_escape_string($conn, $_POST["address"]);
$branch = mysqli_real_escape_string($conn, $_POST["branch"]);
$acno = mysqli_real_escape_string($conn, $_POST["acno"]);
$o_balance = mysqli_real_escape_string($conn, $_POST["o_balance"]);
$pin = mysqli_real_escape_string($conn, $_POST["pin"]);
$cus_uname = mysqli_real_escape_string($conn, $_POST["cus_uname"]);
$cus_pwd = mysqli_real_escape_string($conn, $_POST["cus_pwd"]);
$sql0 = "SELECT MAX(cust_id) FROM customer";
$result = $conn->query($sql0);
$row = $result->fetch_assoc();
$id = $row["MAX(cust_id)"] + 1;
$sql5 = "ALTER TABLE customer AUTO_INCREMENT=".$id;
$conn->query($sql5);
$sql1 = "CREATE TABLE passbook".$id."(
trans_id INT NOT NULL AUTO_INCREMENT,
trans_date DATETIME,
remarks VARCHAR(255),
debit INT,
credit INT,
balance INT,
PRIMARY KEY(trans_id)
)";
$sql2 = "CREATE TABLE beneficiary".$id."(
benef_id INT NOT NULL AUTO_INCREMENT,
benef_cust_id INT UNIQUE,
email VARCHAR(30) UNIQUE,
phone_no VARCHAR(20) UNIQUE,
account_no INT UNIQUE,
PRIMARY KEY(benef_id)
)";
$sql3 = "INSERT INTO customer VALUES(
NULL,
'$fname',
'$lname',
'$gender',
'$dob',
'$aadhar',
'$email',
'$phno',
'$address',
'$branch',
'$acno',
'$pin',
'$cus_uname',
'$cus_pwd'
)";
$sql4 = "INSERT INTO passbook".$id." VALUES(
NULL,
NOW(),
'Opening Balance',
'0',
'$o_balance',
'$o_balance'
)";
?>
<body>
<div class="flex-container">
<div class="flex-item">
<?php
if (($conn->query($sql3) === TRUE)) { ?>
<p id="info"><?php echo "Customer created successfully !\n"; ?></p>
</div>
<div class="flex-item">
<?php
if (($conn->query($sql1) === TRUE)) { ?>
<p id="info"><?php echo "Passbook created successfully !\n"; ?></p>
<?php
} else { ?>
<p id="info"><?php
echo "Error: " . $sql1 . "<br>" . $conn->error . "<br>"; ?></p>
<?php } ?>
</div>
<div class="flex-item">
<?php
if (($conn->query($sql4) === TRUE)) { ?>
<p id="info"><?php echo "Passbook updated successfully !\n"; ?></p>
<?php
} else { ?>
<p id="info"><?php
echo "Error: " . $sql4 . "<br>" . $conn->error . "<br>"; ?></p>
<?php } ?>
</div>
<div class="flex-item">
<?php
if (($conn->query($sql2) === TRUE)) { ?>
<p id="info"><?php echo "Beneficiary created successfully !\n"; ?></p>
<?php
} else { ?>
<p id="info"><?php
echo "Error: " . $sql2 . "<br>" . $conn->error . "<br>"; ?></p>
<?php } ?>
</div>
<?php
} else { ?>
</div>
<div class="flex-item">
<p id="info"><?php
echo "Error: " . $sql3 . "<br>" . $conn->error . "<br>"; ?></p>
<?php } ?>
</div>
<?php $conn->close(); ?>
<div class="flex-item">
<a href="/customer_add.php" class="button">Add Again</a>
</div>
</div>
</body>
</html>