├── README.md
├── connection.php
├── customer.php
├── firsttime.php
├── include
├── footer.php
└── header.php
├── index.php
├── js
└── main.js
├── send.php
└── transaction.php
/README.md:
--------------------------------------------------------------------------------
1 | # Sparks Foundation - Basic Banking System
2 |
3 | ## Index
4 | - [Description](#Description)
5 | - First Time Installation
6 | - How To Run
7 | - Screenshort
8 |
9 | ## Description
10 | - This a Internship project by Sparks Foundation.
11 | - This project is built on HTML/CSS, Bootstrap, PHP and MySQL.
12 | - Details of Customers are maintained as `Name`, `Email`, `Amount` are fields.
13 | - Transaction is done through PDO, If some Error occured while Transaction changes made to table is Rollback(Reverted).
14 |
15 | ## First Time Installation
16 | - Clone the Repository.
17 | - Make sure you have installed XAMP on your computer.
18 | - Copy this folder(Sparks-Foundation) to XAMP installation Directory and then inside htdocs folder.
19 |
20 | ```
21 | For Example
22 | C:\xampp\htdocs\
23 | ```
24 | - Open Xamp Control Panel. Click on Start button near Apache and MySQL.
25 | - Open browser type the following into search bar.
26 | ```
27 | http://localhost/Sparks-Foundation/firsttime.php
28 | ```
29 | - If everything works fine you would see this on your browser.
30 | ```
31 | Conection was established Succesfully.
32 | DATABASE Created Successfully.
33 | Customer Table Created Successfully.
34 | Entries added to table Successfully.
35 | Transaction Table Created Successfully.
36 | ```
37 | - This means that you have created a database name bank, a table name customers also added 10 entries to table and finally creating a table name Transaction.
38 |
39 | ## How To Run
40 | - After following steps above(First Time Installation).
41 | - Make Sure XAMP is active with Apache and MySQL Server Enabled.
42 | - Open Browser Enter the following URL:
43 | ```
44 | http://localhost/Sparks-Foundation/
45 | ```
46 | OR
47 | ```
48 | http://localhost/Sparks-Foundation/index.php
49 | ```
50 | - You will land to Homepage of Money Bank Website.
51 | - Click On `View all Customer` from Navigation OR `Get Started` button for viewing detail of all Customers.
52 | - You will see Customer details in table with deatils like(Name, Email, Current balance, etc.).
53 | - Click on `Send` Button Corresponding Any row of table.
54 | - Now We are on Money Transfering Page. Now Enter a Valid Name in `To` textbox and also Enter Amount, Click on checkbox and finally Click on `Send` Button To Start Transfer.
55 | - Make sure the Amount you enter is not grator then current balance of the Person Selected, else it will pop Message.
56 | - If the Transaction is successful Message will displayed and Changes made by above Transaction will be updated to customer table.
--------------------------------------------------------------------------------
/connection.php:
--------------------------------------------------------------------------------
1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
25 | $db->begintransaction();
26 |
27 | // checking for sufficient for transaction
28 | $sql = 'SELECT amount FROM customers WHERE Name=:from';
29 | $stmt = $db->prepare($sql);
30 | $stmt->execute(array(":from" => $from));
31 | $availableAmount = (int) $stmt->fetchColumn();
32 | $stmt->closeCursor();
33 |
34 | if ($availableAmount < $amount) {
35 | throw new Exception('Insufficient amount to transfer!');
36 | }
37 |
38 | //Preparing SQL statements for transaction
39 | $st1 = $db->prepare(
40 | "update customers set
41 | `Amount`= Amount - :amt where Name = :fro "
42 | );
43 | $st2 = $db->prepare(
44 | "update customers set
45 | `Amount`= Amount + :amt where Name = :to "
46 | );
47 |
48 | $st3 = $db->prepare(
49 | "INSERT INTO `transaction` ( `From`, `To`, `Amount`) VALUES ( :from, :to, :amount)"
50 | );
51 |
52 | //Assigning values to placeholder
53 | $st1->bindValue(':amt', $amount, PDO::PARAM_INT);
54 | $st1->bindValue(':fro', $from, PDO::PARAM_STR);
55 | $st2->bindValue(':amt', $amount, PDO::PARAM_INT);
56 | $st2->bindValue(':to', $to, PDO::PARAM_STR);
57 | $st3->bindValue(':amount', $amount, PDO::PARAM_INT);
58 | $st3->bindValue(':to', $to, PDO::PARAM_STR);
59 | $st3->bindValue(':from', $from, PDO::PARAM_STR);
60 | //Excecuting the SQL Queries
61 | $st1->execute();
62 | $st2->execute();
63 | $st3->execute();
64 | //Checking if user name Exits
65 | if(!$st2->rowCount()||!$st1->rowCount()){
66 | throw new Exception('User not Found!');
67 | }
68 |
69 | //Checking if data is entered into transaction table
70 | if(!$st3->rowCount()) throw new Exception('Could not insert data into Transaction Entry!');
71 |
72 | //Everything is fine so Commit the changes
73 | if($db->commit())
74 | notification("success","Success","Transaction successfull.");
75 | else
76 | notification("danger","Error","Transaction failed!");
77 |
78 | } catch (PDOException $e) { //PDO related Exceptions are handle here
79 | notification("danger","Error",$e->getMessage());
80 | }catch(Exception $e){ //Custom Exceptions are handle here
81 | notification("danger","Error",$e->getMessage());
82 | $db->rollBack(); //Reverting changes if any
83 | }
84 | }
85 |
86 | //Pops up notification about error or sucess messages
87 | function notification($type,$strong,$message){
88 | echo '
Transfering Money is just easy as Dialing a Phone.
40 |
41 |
42 |
43 |
44 |
45 |
Banking is Even Easier
46 |
Visit Our New official Website.
47 |
48 |
49 |
50 |
54 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
Our Services
66 |
67 |
68 |
69 |
Manage Everything at one place
70 |
71 |
To see all Customers
72 |
73 |
74 |
75 |
To see all Transaction
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
About Us
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | Ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
101 | velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
102 | culpa qui officia deserunt mollit anim id est laborum.
103 |