unset($_POST['username']); unset($_POST['password']); $user_details = get_user_details($_SESSION["username"]); $_SESSION['owner_name'] = $user_details['owner_name']; $_SESSION['account_number'] = $user_details['account_number']; $_SESSION['available_funds'] = $user_details['amount']; } else { $_SESSION["failed"] = 'true'; header('Location:login.php'); exit; } } } if (!empty($_SESSION["authenticated"]) && $_SESSION["authenticated"]) { if (array_key_exists('confirm', $_POST)) { $transfer = Banking::tranfer($_SESSION['account_number'], $_SESSION['beneficiary_account'], $_SESSION['amount'], $_SESSION['description']); if ($transfer === 'Your payment is made') { $_SESSION['confirmed'] = $transfer; if (!empty($_SESSION['confirm_url'])) { $_SESSION['confirmation_sent'] = Banklink::send_cofirmation($_SESSION['confirm_url'], $_SESSION['amount'], $_SESSION['description'], $_SESSION['owner_name']); } Banklink::delete_banklink($_SESSION["banklink"]); header('Location:confirmed.php'); exit; } else { echo "<h1>{$transfer}</h1>"; } } if (array_key_exists('cancel', $_POST)) { Banklink::delete_banklink($_SESSION["banklink"]); Banklink::logout();
throw new ExceptionFonduriInsuficiente(); } if ($amount < 0) { throw new ExceptionSumaNegativa(); } $this->balance -= $amount; } } class Banking { private $accounts = array(); public function addAccount(Account $acc) { $this->accounts[] = $acc; } public function displayAccounts() { foreach ($this->accounts as $acc) { echo 'Balance: ' . $acc->getBalance() . '<br/>'; } } } $bank = new Banking(); $a1 = new Account(2300); $a2 = new Account(10000); $bank->addAccount($a1); $bank->addAccount($a2); $bank->displayAccounts(); ?> </body> </html>