diff --git a/f8l_exception/artwork/f8l_exception_logo.png b/f8l_exception/artwork/f8l_exception_logo.png new file mode 100644 index 0000000..e6a7947 Binary files /dev/null and b/f8l_exception/artwork/f8l_exception_logo.png differ diff --git a/f8l_exception/artwork/vault.jpg b/f8l_exception/artwork/vault.jpg new file mode 100644 index 0000000..699fdbe Binary files /dev/null and b/f8l_exception/artwork/vault.jpg differ diff --git a/f8l_exception/change_password.php b/f8l_exception/change_password.php new file mode 100644 index 0000000..5463a47 --- /dev/null +++ b/f8l_exception/change_password.php @@ -0,0 +1,99 @@ + + + + + + + F8L Exception Online Bank | Change Password + + +

Change Password


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $sql = "UPDATE user SET password='$newPassword' WHERE username='$userName'"; + $result = mysql_query($sql); + } + mysql_close($db_connect); + } + return ($retval); +} + +function displayForm($userName) { + global $errorMessage; + echo $errorMessage; + ?> +
+

User Name:

+

Old Password:

+

New Password:

+

Confirm New Password:

+ +

+
+

+ + "; + $errorCount++; + } + if ($errorCount == 0) + $showForm = FALSE; + else + $showForm = TRUE; +} + +if ($showForm == TRUE) { + if ($errorCount > 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm ($userName); +} +else { + // encrypt password here + + // change password in db + changePassword($userName,$oldPassword,$newPassword); + echo "

\nPassword has been changed!.



\n"; + include 'includes/inc_text_menu.php'; +} +?> + + + \ No newline at end of file diff --git a/f8l_exception/deposit.php b/f8l_exception/deposit.php new file mode 100644 index 0000000..48a7e1c --- /dev/null +++ b/f8l_exception/deposit.php @@ -0,0 +1,70 @@ + + + + + + + F8L Exception Online Bank | Deposit + + +

Deposit -- under construction


+ + + + +

Enter your User Name and Password.

+ +
+

User Name

+

Password

+

+
+

+ + 0) { // errors logged + displayForm(); + } +else { + if ($ShowForm == TRUE) { + displayForm(); // new page load + } + else { // login approved + $_SESSION['login'] = $Login; + //header("location:my_documents.php"); + ?> + + + \ No newline at end of file diff --git a/f8l_exception/includes/inc_dbConnect.php b/f8l_exception/includes/inc_dbConnect.php new file mode 100644 index 0000000..7043044 --- /dev/null +++ b/f8l_exception/includes/inc_dbConnect.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/f8l_exception/includes/inc_generatePassword.php b/f8l_exception/includes/inc_generatePassword.php new file mode 100644 index 0000000..19edb5b --- /dev/null +++ b/f8l_exception/includes/inc_generatePassword.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/f8l_exception/includes/inc_getNumberOfAccounts.php b/f8l_exception/includes/inc_getNumberOfAccounts.php new file mode 100644 index 0000000..09a9eb4 --- /dev/null +++ b/f8l_exception/includes/inc_getNumberOfAccounts.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/f8l_exception/includes/inc_header.php b/f8l_exception/includes/inc_header.php new file mode 100644 index 0000000..97bae72 --- /dev/null +++ b/f8l_exception/includes/inc_header.php @@ -0,0 +1 @@ +F8L Exception Online Bank \ No newline at end of file diff --git a/f8l_exception/includes/inc_text_menu.php b/f8l_exception/includes/inc_text_menu.php new file mode 100644 index 0000000..4ea5087 --- /dev/null +++ b/f8l_exception/includes/inc_text_menu.php @@ -0,0 +1,17 @@ +Home | +New Customer | +Login | +Change Password | +Reset Password | +Logout +
+New Account | +My Accounts | +Deposit | +Withdraw | +View Statement +
+New Loan | +Make Loan Payment +
+Admin \ No newline at end of file diff --git a/f8l_exception/includes/inc_validateEmail.php b/f8l_exception/includes/inc_validateEmail.php new file mode 100644 index 0000000..26112f9 --- /dev/null +++ b/f8l_exception/includes/inc_validateEmail.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/f8l_exception/includes/inc_validateInput.php b/f8l_exception/includes/inc_validateInput.php new file mode 100644 index 0000000..fe54c9e --- /dev/null +++ b/f8l_exception/includes/inc_validateInput.php @@ -0,0 +1,20 @@ +\n"; + $errorCount++; + $retval = ""; + } + else + { + // only clean up the input if it isn't empty + $retval = trim($data); + $retval = stripslashes($retval); + } + return ($retval); +} +?> \ No newline at end of file diff --git a/f8l_exception/includes/inc_validateLogin.php b/f8l_exception/includes/inc_validateLogin.php new file mode 100644 index 0000000..3cd315f --- /dev/null +++ b/f8l_exception/includes/inc_validateLogin.php @@ -0,0 +1,34 @@ +\n"; + } + mysql_close($db_connect); + return $myusername; +} +?> \ No newline at end of file diff --git a/f8l_exception/includes/inc_validatePassword.php b/f8l_exception/includes/inc_validatePassword.php new file mode 100644 index 0000000..7f39223 --- /dev/null +++ b/f8l_exception/includes/inc_validatePassword.php @@ -0,0 +1,60 @@ +\n"; + $errorCount++; + $retval = ""; + } + elseif ($data !== $data2) + { + $errorMessage .= "Passwords do not match.
\n"; + $errorCount++; + $retval = ""; + } + elseif (strlen($data) < 8) + { + $errorMessage .= "Password must be at least 8 characters, + must contain at least one upper case letter, at least one lower case letter, + at least one number, and at least one non-alphanumeric character.
\n"; + $errorCount++; + $retval = ""; + } + elseif (!containsUpper($data) or !containsLower($data) or !containsNumber($data) or + !containsOther($data) or containsSpaces($data)) + { + $errorMessage .= "Password must be at least 8 characters, + must contain at least one upper case letter, at least one lower case letter, + at least one number, and at least one non-alphanumeric character.
\n"; + $errorCount++; + $retval = ""; + } + else + { + // only clean up the input if it isn't empty + $retval = trim($data); + $retval = stripslashes($retval); + } + return ($retval); +} +?> \ No newline at end of file diff --git a/f8l_exception/includes/inc_validateUserName.php b/f8l_exception/includes/inc_validateUserName.php new file mode 100644 index 0000000..23dbfdd --- /dev/null +++ b/f8l_exception/includes/inc_validateUserName.php @@ -0,0 +1,48 @@ +\n"; + $errorCount++; + $retval = ""; + } + + elseif (strlen($data) < 4 || strlen($data) > 30) { + $errorMessage .= $fieldName . " must be at least 4 and at most 30 characters.
\n"; + $errorCount++; + } + + else { + include 'includes/inc_dbConnect.php'; + + // Select database. + if ($db_connect === FALSE) + echo "

Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $SQLstring = "SELECT * FROM user WHERE username = '$data'"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + if (mysql_num_rows($QueryResult) > 0) { + //echo "Please select a different User Name.
\n"; + $errorMessage .= "Please select a different User Name.
\n"; + $errorCount++; + $retval = ""; + } + else { + $retval = trim($data); + $retval = stripslashes($retval); + } + } + mysql_close($db_connect); + } + } + return ($retval); +} +?> \ No newline at end of file diff --git a/f8l_exception/index.php b/f8l_exception/index.php new file mode 100644 index 0000000..74950a5 --- /dev/null +++ b/f8l_exception/index.php @@ -0,0 +1,23 @@ + + + + + + + F8L Exception Online Bank | Home + + +

Welcome to F8L Exception Online Bank!


+ + + +

Secure online banking with zero fees

+ +

What? You're looking for a secure and reliable online bank to stash your cash in that won't bury you with fees? The F8L Exception Online Bank has it all. +It is free, quick and easy to set up an account, and you can access all your funds conveniently online.

+
+ \ No newline at end of file diff --git a/f8l_exception/loan_payment.php b/f8l_exception/loan_payment.php new file mode 100644 index 0000000..840b96e --- /dev/null +++ b/f8l_exception/loan_payment.php @@ -0,0 +1,124 @@ + + + + + + + F8L Exception Online Bank | Make a Loan Payment + + +

Make a Loan Payment -- Under construction


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $today = date("Ymd"); + $TableName = "account"; + $SQLstring = "INSERT INTO + $TableName (login,password,firstName,lastName,email,active,dateOpened) + VALUES ('$Login','$Password','$First','$Last','$Email',1,'$today')"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + } + mysql_close($db_connect); + } + return ($retval); +} + +function displayForm($First, $Last, $Email, $Login) { + global $errorMessage; + echo $errorMessage; + ?> +
+

First Name:

+

Last Name:

+

Your E-Mail:

+

User Name:

+

Password:

+

Confirm Password:

+ +

+
+

+ + "; + $errorCount++; + } + if ($errorCount == 0) + $showForm = FALSE; + else + $showForm = TRUE; +} + +if ($showForm == TRUE) { + if ($errorCount > 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm ($First, $Last, $Email, $Login); +} +else { + // encrypt password + //$options = array('cost' => 11); + //$password = password_hash($password, PASSWORD_BCRYPT, $options); + + // create account in db + createNewAccount($First,$Last,$Email,$Login,$Password); + + // send confirmation email + $SenderAddress = "$First <$Email>"; + $Headers = "From: $SenderAddress\nCC:$SenderAddress\n"; + + $from = "PVault"; // sender + $subject = "PVault Registration Confirmation"; + $message = $First . ",\nYou have successfully registered for PVault. Now you can Store your documents in the cloud, securely locked inside your own Personal Vault.\n\nThe PVault Team"; + // message lines should not exceed 70 characters (PHP rule), so wrap it + $message = wordwrap($message, 70); + // send mail + mail($Email,$subject,$message,"From: $from\n"); + + echo "

" . $First . "\nyour account has been created. Welcome to PVault!.



\n"; + include 'includes/inc_text_menu.php'; +} +?> + + + \ No newline at end of file diff --git a/f8l_exception/login.php b/f8l_exception/login.php new file mode 100644 index 0000000..e9117fe --- /dev/null +++ b/f8l_exception/login.php @@ -0,0 +1,71 @@ + + + + + + + F8L Exception Online Bank | Login + + +

Login


+ + + + +

Enter your User Name and Password.

+ +
+

User Name

+

Password

+

+
+

+ + 0) { // errors logged + displayForm(); + } +else { + if ($ShowForm == TRUE) { + displayForm(); // new page load + } + else { // login approved + $_SESSION['login'] = $userName; + //header("location:my_documents.php"); + ?> + + + \ No newline at end of file diff --git a/f8l_exception/logout.php b/f8l_exception/logout.php new file mode 100644 index 0000000..6f7661f --- /dev/null +++ b/f8l_exception/logout.php @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/f8l_exception/my_accounts.php b/f8l_exception/my_accounts.php new file mode 100644 index 0000000..1ef5b55 --- /dev/null +++ b/f8l_exception/my_accounts.php @@ -0,0 +1,64 @@ + + + + + + + F8L Exception Online Bank | My Accounts + + +

My Accounts


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $SQLstring = "SELECT * from account + WHERE username='$userName'"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + if (mysql_num_rows($QueryResult) == 0) + echo "

You have no accounts open.

"; + else { + echo ""; + echo " + + + + "; + while (($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) + { + echo ""; + echo ""; + echo ""; + } + echo "
Account TypeAccount NumberBalance
{$Row['accounttype']}{$Row['accountid']}{$Row['balance']}


"; + } + } + mysql_close($db_connect); + } + return ($retval); +} + +$userName = ""; +$userName = $_SESSION['login']; +echo "User Name: ".$userName."
"; +showAccounts($userName); + +include 'includes/inc_text_menu.php'; + +?> + + + \ No newline at end of file diff --git a/f8l_exception/new_account.php b/f8l_exception/new_account.php new file mode 100644 index 0000000..d274b94 --- /dev/null +++ b/f8l_exception/new_account.php @@ -0,0 +1,103 @@ + + + + + + + F8L Exception Online Bank | Open New Account + + +

Open a New Account


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $today = date("Ymd"); + $TableName = "account"; + $SQLstring = "INSERT INTO + $TableName (login,password,firstName,lastName,email,active,dateOpened) + VALUES ('$Login','$Password','$First','$Last','$Email',1,'$today')"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + } + mysql_close($db_connect); + } + return ($retval); +} + +function displayForm($First, $Last, $Email, $Login) { + global $errorMessage; + echo $errorMessage; + + // figure out how to make a checkbox for savings or checking in this form. + ?> +
+

Initial Deposit:

+

Account Type:

+ +

+
+

+ + 1) + echo "You already have two accounts open. Each user is limited to two accounts."; +else { + $showForm = TRUE; + if (isset($_POST['Submit'])) { + $balance = validateInput($_POST['balance'],"Initial Deposit"); + $accountType = validateInput($_POST['accountType'],"Account Type"); +// gotta finish coding all this stuff below. + if($Login == $Password) { + $errorMessage .= "Password cannot be the same as user name
"; + $errorCount++; + } + if ($errorCount == 0) + $showForm = FALSE; + else + $showForm = TRUE; + } + + if ($showForm == TRUE) { + if ($errorCount > 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm (); + } + else { + // create account in db + createNewAccount($userName,$balance,$accountType); + + echo "

Your account has been created!.



\n"; + } +} +include 'includes/inc_text_menu.php'; +?> + + + \ No newline at end of file diff --git a/f8l_exception/new_customer.php b/f8l_exception/new_customer.php new file mode 100644 index 0000000..309c17b --- /dev/null +++ b/f8l_exception/new_customer.php @@ -0,0 +1,116 @@ + + + + + + + F8L Exception Online Bank | Register a New Customer + + +

Register a New Customer


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $errorMessage .= "Inserting new user into db."; + echo "Inserting new user into db. $userName $pw $email"; + $SQLstring = "INSERT INTO + user (username,password,email) + VALUES ('$userName','$pw','$email')"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + } + mysql_close($db_connect); + } + return ($retval); +} + +function displayForm($userName,$email) { + global $errorMessage; + echo $errorMessage; + ?> +
+

User Name:

+

Email:

+

Password:

+

Confirm Password:

+ +

+
+

+ + "; + $errorCount++; + } + if ($errorCount == 0) + $showForm = FALSE; + else + $showForm = TRUE; +} + +if ($showForm == TRUE) { + if ($errorCount > 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm ($userName,$email); +} +else { + // should add password encryption code here + + // create account in db + createNewCustomer($userName, $password, $email); + + // send confirmation email + $SenderAddress = "F8L Exception Bank Customer <$email>"; + $Headers = "From: $SenderAddress\nCC:$SenderAddress\n"; + + $from = "F8L Exception Online Bank"; // sender + $subject = "F8L Exception Online Bank New Customer Confirmation"; + $message = "You have successfully registered as a new customer for F8L Exception Online Bank. We hope you will enjoy our service and our lack of fees!\n\nThe F8L Exception Online Bank"; + // message lines should not exceed 70 characters (PHP rule), so wrap it + $message = wordwrap($message, 70); + // send mail + mail($email,$subject,$message,"From: $from\n"); + + echo "

You have been set up as a new customer. Welcome to F8L Exception Online Bank!.



\n"; + include 'includes/inc_text_menu.php'; +} +?> + + + \ No newline at end of file diff --git a/f8l_exception/new_loan.php b/f8l_exception/new_loan.php new file mode 100644 index 0000000..109430b --- /dev/null +++ b/f8l_exception/new_loan.php @@ -0,0 +1,124 @@ + + + + + + + F8L Exception Online Bank | New Loan + + +

New Loan -- Under construction


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + $today = date("Ymd"); + $TableName = "account"; + $SQLstring = "INSERT INTO + $TableName (login,password,firstName,lastName,email,active,dateOpened) + VALUES ('$Login','$Password','$First','$Last','$Email',1,'$today')"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + } + mysql_close($db_connect); + } + return ($retval); +} + +function displayForm($First, $Last, $Email, $Login) { + global $errorMessage; + echo $errorMessage; + ?> +
+

First Name:

+

Last Name:

+

Your E-Mail:

+

User Name:

+

Password:

+

Confirm Password:

+ +

+
+

+ + "; + $errorCount++; + } + if ($errorCount == 0) + $showForm = FALSE; + else + $showForm = TRUE; +} + +if ($showForm == TRUE) { + if ($errorCount > 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm ($First, $Last, $Email, $Login); +} +else { + // encrypt password + //$options = array('cost' => 11); + //$password = password_hash($password, PASSWORD_BCRYPT, $options); + + // create account in db + createNewAccount($First,$Last,$Email,$Login,$Password); + + // send confirmation email + $SenderAddress = "$First <$Email>"; + $Headers = "From: $SenderAddress\nCC:$SenderAddress\n"; + + $from = "PVault"; // sender + $subject = "PVault Registration Confirmation"; + $message = $First . ",\nYou have successfully registered for PVault. Now you can Store your documents in the cloud, securely locked inside your own Personal Vault.\n\nThe PVault Team"; + // message lines should not exceed 70 characters (PHP rule), so wrap it + $message = wordwrap($message, 70); + // send mail + mail($Email,$subject,$message,"From: $from\n"); + + echo "

" . $First . "\nyour account has been created. Welcome to PVault!.



\n"; + include 'includes/inc_text_menu.php'; +} +?> + + + \ No newline at end of file diff --git a/f8l_exception/reset_password.php b/f8l_exception/reset_password.php new file mode 100644 index 0000000..2984823 --- /dev/null +++ b/f8l_exception/reset_password.php @@ -0,0 +1,120 @@ + + + + + + + F8L Exception Online Bank | Reset Password + + +

Reset Password


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

Connection error. Please try again later.

"; + else { + // check login for validity + $sql = "SELECT * FROM user WHERE username='$userName' and email='$email'"; + $result = mysql_query($sql); + + // Mysql_num_row is counting table rows + $count = mysql_num_rows($result); + + // If result matched $userName, table row must be 1 row. Get Email address, and Reset PW + if($count == 1){ + $row = mysql_fetch_row($result); + //$email = $row[5]; + $newPassword = generatePassword(); + $sql = "UPDATE user SET password='$newPassword' WHERE username='$userName'"; + $result = mysql_query($sql); + } + else { + $errorCount++; + $errorMessage .= "Account not found. Please re-enter your User Name and Email.
\n"; + } + mysql_close($db_connect); + + return $newPassword; + } + } +} +function displayForm() { + global $errorMessage; + echo $errorMessage; + ?> +
+

User Name:

+

Email:

+

+
+

+ + 0) // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm (); +} +else { + $newPassword = resetPassword($userName); + if ($errorCount > 0) { // if there were errors + $errorMessage .= "

Please re-enter the form information below.

\n"; + displayForm (); + } + else { + echo "

\nPassword has been reset!. A new password has been emailed to you.



\n"; + include 'includes/inc_text_menu.php'; + + // send confirmation email + $SenderAddress = "<$email>"; + $Headers = "From: $SenderAddress\nCC:$SenderAddress\n"; + + $from = "F8L Exception Online"; // sender + $subject = "F8L Exception Online Bank Password Reset"; + $message = "Your new password is $newPassword\nWe recommend you login using this password and change it to a new password of your choosing.\n\nF8L Exception Online Bank"; + // message lines should not exceed 70 characters (PHP rule), so wrap it + $message = wordwrap($message, 70); + // send mail + mail($email,$subject,$message,"From: $from\n"); + } +} +?> + + + \ No newline at end of file diff --git a/f8l_exception/view_statement.php b/f8l_exception/view_statement.php new file mode 100644 index 0000000..87f2c3a --- /dev/null +++ b/f8l_exception/view_statement.php @@ -0,0 +1,85 @@ + + + + + + + F8L Exception Online Bank | View Statement + + +

View Statement -- Under construction


+ + + +Unable to connect to the database server.

" . "

Error code " . mysql_errno() . ": " . mysql_error() . "

"; + + else { + if (!@mysql_select_db($db_name, $db_connect)) + echo "

No data found.

"; + else { + + $TableName = "document"; + $SQLstring = "SELECT * FROM $TableName WHERE login = '$Login' and active = 1"; + + $QueryResult = @mysql_query($SQLstring, $db_connect); + if (mysql_num_rows($QueryResult) == 0) + echo "

No data found .

"; + else + { + echo ""; + echo " + + + + + + + "; + while (($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) + { + echo ""; + echo ""; + echo ""; + echo ""; + ?> + +

"; + } + mysql_free_result($QueryResult); + } + } + include 'includes/inc_text_menu.php'; +} +$Login = ""; +$Login = $_SESSION['login']; +if ($Login == "") { // redirect to login page if not logged in + ?> + + + \ No newline at end of file diff --git a/f8l_exception/withdraw.php b/f8l_exception/withdraw.php new file mode 100644 index 0000000..49f8a1b --- /dev/null +++ b/f8l_exception/withdraw.php @@ -0,0 +1,70 @@ + + + + + + + F8L Exception Online Bank | Withdraw + + +

Withdraw -- Under construction


+ + + + +

Enter your User Name and Password.

+ + +

User Name

+

Password

+

+ +

+ + 0) { // errors logged + displayForm(); + } +else { + if ($ShowForm == TRUE) { + displayForm(); // new page load + } + else { // login approved + $_SESSION['login'] = $Login; + //header("location:my_documents.php"); + ?> + + + \ No newline at end of file diff --git a/proj.txt b/proj.txt index 66d4319..eae6759 100644 --- a/proj.txt +++ b/proj.txt @@ -4,54 +4,59 @@ Project Title: Online Banking System Link to Github: https://github.com/dhurng/cs157AOnlineBanking/edit/master/proj.txt Database Schema -1. Users {id, username, password, checkingAmount, savingsAmount} - int id: autogenerated id number. - String username: Customer's account username. - String password: Customer's account password. - boolean checkingAmount: yes if customer has a checking account. - boolean savingsAmount: yes if customer has a savings account. +1. User {userId, username, password, loanId, accountId1, accountId2} + int userId: autogenerated user id number. + String username: Customer's username. + String password: Customer's password. + int loanId: loan number, if user has a loan. + int accountId1: account number for first account + int accountId2: account number for second account -2. Transfer {id1, id2, amount, checking, savings} - int id1: sender. - int id2: recipient. +2. Transfer {id1, id2, amount} + int id1: sender account. + int id2: recipient account. double amount: amount to transfer. - boolean checking: true if amount is coming from checking account. - boolean savings: true if amount is coming from savings account. -3. Loan {id, date, overdue, amount, balance} - int id: sender. - Date date: date of payment. - boolean overdue: true if payment is late. +3. Loan {loanId, userId, amount, paymentDueDate, paymentDate balance} + int loanId: loan number. + int userId: user who owns this loan. double amount: amount to pay. + Date paymentDueDate: date payment is due + Date paymentDate: date most recent payment was made double balance: remaining balance. - -4. Checking {id, balance, amount} - int id: customer id. - double balance: checking balance. - double amount: amount to withdraw or deposit. -5. Savings {id, balance, interestRate, amount} - int id: customer id. - double balance: savings balance. - double interestRage: interest rate to add to balance. - double amount: amount to withdraw or deposit. +4. Account {accountId, userId, balance, interestRate, accountType} + int accountId: account number. + int userId: user who owns this account. + double balance: account balance. + double interestRate: interest rate to add to balance. + String accountType: account type - savings, checking + +5. Transaction {userId, accountId, accountType, date, amount, transactionType, toId} + int userId: customer id + int accountId: account number or loan number + String accountType: checking, savings, loan + Date date: date of transaction + double amount: transaction amount + String transactionType: transaction type - deposit, withdraw, interest, payment + int toId: to customer id, for transfers Functional Requirements -1. Customer can register to create an account. -2. Customer can close their account. -3. Customer can log into their account. -4. Customer can log out of their account. +1. Customer can register to create a new user. +2. Customer can open a new account. +3. Customer can close their account. +4. Customer can log into their account. 5. Customer can change password. 6. Customer can reset their password. -7. Customer can check their checking account balance. -8. Customer can check their savings account balance. -9. Customer can withdraw from their accounts. -10. Customer can deposit to their accounts. +7. Customer can check their checking or savings account balance. +8. Customer can check their loan balance. +9. Customer can withdraw from their checking or savings accounts. +10. Customer can deposit to their checking or savings accounts. 11. Customer can view their statements from each account (Checking and Savings). -12. Customer can pay their credit card bill. +12. Customer can pay their loan payment. 13. Administrator can reset non-Admin password. 14. Administrator can view customers who have a zero balance in their checking and/or savings account. -15. Administrator can view who is a late paying their credit card bill. +15. Administrator can view who is a late paying their loan payment. Requirements Functionalities //Send Query to Database @@ -62,47 +67,115 @@ function queryMysql($query){ return $result; } -// Customer Registration -function registration ($username, $password, $checkAmount, $savingsAmount){ - $result = queryMysql("INSERT INTO Users(username, password, checkingAmount, savingsAmount) - VALUES ('$username', '$password', '$checkAmount', '$savingsAmount'"); +// 1. Customer Registers to Create new User +function registerUser ($username, $password){ + $result = queryMysql("INSERT INTO User(username, password) + VALUES ('$username', '$password'", $link) or die ("Database Error"); } -// Customer Account Cancellation -function cancelAccount ($username){ - $result = queryMysql("DELETE FROM Users WHERE username = '$username'"); +//2. Customer opens a New Account +function registerAccount ($userid, $initialAmount, $accountType){ + $result = queryMysql("INSERT INTO Account(userId, balance, accountType) + VALUES ('$userId', '$initialAmount', '$accountType'", $link) or die ("Database Error"); + $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) + VALUES ('$userId', 'accountId', '$accountType', '$initialAmount', '$today'", $link) or die ("Database Error"); + +// 3. Customer Closes Account +function cancelAccount ($userId, $accountId){ + $result = queryMysql("DELETE FROM Account WHERE userId='$userId' and accountId='$accountId'", $link) + or die ("Database Error"); } -// Customer Log In +// 4. Customer Logs In function userLogIn ($username, $password){ - $result = queryMysql("SELECT * FROM Users WHERE username='$username' and password='$password'"); + $result = queryMysql("SELECT * FROM User WHERE username='$username' and password='$password'", $link) or die ("Database Error"); } -// Customer Change Password +// 5. Customer Changes Password function checkPassword($username, $oldPass, $newPass){ - $result = queryMysql("UPDATE Users SET password = '$newPass' WHERE old.password='$oldPass'"); + $result = queryMysql("UPDATE User SET password = '$newPass' + WHERE username='$username' and password='$oldPass'", $link) or die ("Database Error"); } -// Reset Customer Password -function resetPassword ($username) { +// 6. Reset Customer Password +function resetPassword ($username, $userId) { $salt1 = "qm&h"; $token = hash('f8luser', "$salt1'somePassword'"); - $result = queryMysql("UPDATE Users SET password='$token'"); + $result = queryMysql("UPDATE User SET password='$token' + WHERE username='$username' and userId='$userId'", $link) or die ("Database Error"); return $token; } -//Check Checking Account Balance -function check_CheckingBalance ($checkingsAccount) { +// 7. Check Checking Account Balance +function get_CheckingBalance ($username, $accountId) { include 'db_connect.php'; - $result=mysql_query("SELECT * FROM checkingsAccount ORDER BY account_type", $link) or die ("Database Error"); + $result=mysql_query("SELECT balance FROM account + WHERE accountType='checking' and username='$username' and accountId='$accountId'", $link) + or die ("Database Error"); } -//Check Savings Account Balance -function check_SavingBalance ($savingsAccount) { +// 8. Check Savings Account Balance +function check_SavingBalance ($username, $accountId) { include 'db_connect.php'; - $result=mysql_query("SELECT * FROM savingsAccount ORDER BY account_type", $link) or die ("Database Error"); + $result=mysql_query("SELECT balance FROM account + WHERE accountType='savings' and username='$username' and accountId='$accountId'", $link) + or die ("Database Error"); } -//Withdraw from Accounts -function withdraw ($ -//Deposit into Account +// 9. Customer can withdraw from their accounts. +function accountWithdraw($userId, $accountId, $accountType, $amount) { + include 'db_connect.php'; + $result=mysql_query("UPDATE Account SET balance=balance-'$amount' + WHERE userId='$userId' and accountId='$accountId'", $link) or die ("Database Error"); + $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) + VALUES ('$userId', 'accountId', '$accountType', '$amount', '$today'", $link) + or die ("Database Error"); +} + +// 10. Customer can deposit to their accounts. +function accountDeposit($userId, $accountId, $accountType, $amount) { + include 'db_connect.php'; + $result=mysql_query("UPDATE Account SET balance=balance+'$amount' + WHERE userId='$userId' and accountId='$accountId'", $link) or die ("Database Error"); + $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) + VALUES ('$userId', 'accountId', '$accountType', '$amount', '$today'", $link) + or die ("Database Error"); +} + +// 11. Customer can view their statements from each account (Checking and Savings). +function viewStatement($userId) { + include 'db_connect.php'; + $result=mysql_query("SELECT accountType, date, transactionType, amount + FROM Transaction GROUP BY accountType + HAVING userId='$userId' ORDER BY date", $link) or die ("Database Error"); +} + +// 12. Customer can pay their loan payment. +function loanPayment($userId, $loanId, $amount) { + include 'db_connect.php'; + $result=mysql_query("UPDATE Loan SET balance=balance-'$amount', paymentDate='$today' + WHERE userId='$userId' and loanId='$loanId'", $link) or die ("Database Error"); + $result = queryMysql("INSERT INTO Transaction(userId, loanId, accountType, amount) + VALUES ('$userId', 'loanId', 'loan', '$amount'", $link) or die ("Database Error"); +} + +// 13. Administrator can reset non-Admin password. +function adminResetUserPassword ($userId, $newPassword) { + include 'db_connect.php'; + $result = queryMysql("UPDATE User SET password='$newPassword' WHERE userId='$userId'", $link) + or die ("Database Error"); +} + +// 14. Administrator can view customers who have a zero balance in their checking and/or savings account. +function adminGetPoorUsers() { + include 'db_connect.php'; + $result = queryMysql("SELECT userId FROM User WHERE balance<=0", $link) + or die ("Database Error"); +} + +// 15. Administrator can view who is late paying their loan payment. +function adminGetUsersOfOverdueLoans() { + include 'db_connect.php'; + $result=mysql_query("SELECT userId FROM User + WHERE userId IN (SELECT userId FROM Loan + WHERE paymentDueDate
TitleTagsRevised DateNote1EditRemove
{$Row['title']}{$Row['tags']}{$Row['revisedDate']}{$Row['note1']} +
+ + + +
+
+
+ + + +
+