PHP Programming/Coding Standards

Indenting and Line Length.
Use an indent of one tab (no spaces! Good IDEs can convert this to pseudo spaces - 2, 4, etc.). If you use Emacs to edit your code, you should set indent-tabs-mode to nil. It is recommended that you break lines at approximately 75-85 characters. There is no standard rule for the best way to break a line; use your judgement. This applies to all file types: PHP, HTML, CSS, JavaScript, etc.
Indentation rules should be applied in the source file that will be edited by others. The visual appeal of HTML output should not be taken into consideration when writing code that generates HTML.
HTML Standards.
Validation.
As of September 2006, the DocType on our documents will be XHTML 1.0 Transitional. Therefore, compliant HTML according to the XHTML 1.0 standard should be used at all times. Exceptions should be just that. A good reference for the XHTML elements can be found at DevGuru.
Also, to ensure that the box model is done correctly by Internet Explorer 6, we must use the following DocType on all pages. Only this doc type is to be used. No other information should be placed before it.
Element Usage.
When at all possible, try and use standard HTML elements properly. "Div Soup" should be avoided at all times. "Div Soup" refers to HTML where a div (or span) is used when it is not needed. For example, if you need a word to be bolded, do not use a &lt;span&gt; tag and apply a style. Instead, use the &lt;strong&gt; tag.
Tables should be used only when data needs to be displayed in columns. One cell tables should never be used. 
One common exception is needing to use &lt;div&gt; tags in place of &lt;p&gt; tags when the contents of the tag will be other block level elements such as &lt;ul&gt;.
CSS Standards.
Inline styles should be avoided!
Styles in CSS files should be as specific as possible. One should always try to avoid using a bare class name. If you are styling an object that has a container, your style should reference the continer as well as the element being styled. The more verbose your styles in your CSS the less likely you will mess up another element on another page accidentally.
The most efficient way to style an element is by styling that type of element inside a container. If only one element needs to be styled in a special way, it should be assigned and id and styled using the id and preferably a container.
Here is some HTML from our sidebar:
And here is a small bit of how we style those elements.
This verbosity ensures that other elements are not accidentally styled.
&lt;?php
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
require_once('functions/base_url.php');
if (session_status() == PHP_SESSION_NONE) {
 session_start();
// database connect file check
!file_exists('functions/Connect_db.php') ? header('Location: ' . $base_url . 'functions/databaseSettings.php') : ";
require_once('functions/Connect_db.php');
require_once('functions/SqlQuery.php');
require_once('functions/CheckerFn.php');
require_once('currencyAndIcons.php');
require_once('SendMail.php');
class Action
 public $db;
 public $checker;
 public $theDay;
 public function __construct()
 $this-&gt;db = new SqlQuery;
 $this-&gt;theDay = date('Y-m-d');
 $this-&gt;checker = new CheckerFn;
 // company settings manage add, update
 public function manageSettings()
 $logo = ";
 $companyName = $this-&gt;checker-&gt;c_valid($_POST['companyName']);
 $userCurrency = $this-&gt;checker-&gt;c_valid($_POST['userCurrency']);
 $smtpHost = $this-&gt;checker-&gt;c_valid($_POST['smtpHost']);
 $smtpPort = $this-&gt;checker-&gt;c_valid($_POST['smtpPort']);
 $smtpAuth = $this-&gt;checker-&gt;c_valid($_POST['smtpAuth']);
 $contactEmail = $this-&gt;checker-&gt;c_valid($_POST['contactEmail']);
 $emailPassword = $this-&gt;checker-&gt;c_valid($_POST['emailPassword']);
 $startingDate = $this-&gt;checker-&gt;c_valid($_POST['startingDate']);
 if (!empty($_FILES['logo']['name'])) {
 $logo_array = $_FILES['logo'];
 $name = explode('.', $logo_array['name']);
 $logo = md5(rand() . time()) . '.' . end($name);
 } else {
 $logo = $this-&gt;checker-&gt;c_valid($_POST['preLogo']);
 $data = [
 'companyName' =&gt; $companyName,
 'companyLogo' =&gt; $logo,
 'userCurrency' =&gt; $userCurrency,
 'smtpHost' =&gt; $smtpHost,
 'smtpPort' =&gt; $smtpPort,
 'smtpAuth' =&gt; $smtpAuth,
 'contactEmail' =&gt; $contactEmail,
 'emailPassword' =&gt; $emailPassword,
 'startingDate' =&gt; $startingDate
 // check smtp connection
 $smtpCheck = fsockopen($smtpHost, $smtpPort, $errno, $errstr, 6);
 if (is_bool($smtpCheck) &amp;&amp; $smtpCheck === false) {
 $_SESSION['smtpInvalid'] = $data;
 return $this-&gt;checker-&gt;redirect('settings');
 if (isset($_SESSION['atFirstSettings'])) {
 $insertSuccess = $this-&gt;db-&gt;insertAction('company_settings', $data);
 if (isset($insertSuccess)) {
 unset($_SESSION['atFirstSettings']);
 move_uploaded_file($logo_array['tmp_name'], 'img/' . $logo);
 return $this-&gt;checker-&gt;redirect('registerPartner');
 } elseif (isset($_POST['settingsEdit'])) {
 $id = $this-&gt;checker-&gt;c_valid($_POST['settingsEdit']);
 $success = $this-&gt;db-&gt;updateAction('company_settings', $data, ['id' =&gt; $id]);
 if (isset($success)) {
 if ($logo !== $_POST['preLogo']) {
 $_SESSION['logo'] = $logo;
 unlink('img/' . $_POST['preLogo']);
 move_uploaded_file($logo_array['tmp_name'], 'img/' . $logo);
 $_SESSION['settingsUpdated'] = 1;
 $_SESSION['currency'] = currency_symbol($userCurrency);
 return $this-&gt;checker-&gt;redirect('manageSettings');
 // user account recovery method if user forgot user account informetion
 public function getAccount($getBy)
 // user account information get by email
 $getAccount;
 if ($getBy === '010') {
 $email = $this-&gt;checker-&gt;c_valid($_POST['email']);
 if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
 $emailExist = $this-&gt;db-&gt;get_row("fms_admin", ['email' =&gt; $email]);
 if (isset($emailExist) &amp;&amp; $emailExist) {
 $getAccount = $emailExist;
 } else {
 $_SESSION['doesNotExist_e'] = $email;
 return $this-&gt;checker-&gt;redirect('forgotPassword');
 } else {
 $_SESSION['invalidEmail'] = $email;
 return $this-&gt;checker-&gt;redirect('forgotPassword');
 // to get user account information by user full name &amp; birthday
 if ($getBy === '101') {
 $fullName = $this-&gt;checker-&gt;c_valid($_POST['fn']) . ' ' . $this-&gt;checker-&gt;c_valid($_POST['ln']);
 $birthday = $this-&gt;checker-&gt;c_valid($_POST['birthday']);
 $userExist = $this-&gt;db-&gt;get_row('fms_admin', ['fullName' =&gt; $fullName, 'birthday' =&gt; $birthday]);
 if (isset($userExist)) {
 $userExist = $getAccount;
 } else {
 $_SESSION['actionfaild'] = 1;
 return $this-&gt;checker-&gt;redirect('forgotPassword');
 // check user is exists
 if (isset($getAccount)) {
 $email = $getAccount['email'];
 $userName = $getAccount['userName'];
 $fullName = $getAccount['fullName'];
 $sec = json_decode($getAccount['userInfo_sc']); // secure informetion container
 $password = md5(sha1($userName . rand()));
 $sec_one = md5(sha1($password . rand()));
 $sec_two = md5(sha1($sec_one . rand()));
 $setLink = $this-&gt;checker-&gt;base_url() . 'resetPassword.php?' . $userName . '=' . $password . '&amp;' . $sec_one . '=' . $sec_two;
 $getEmail = $this-&gt;db-&gt;get_row("company_settings");
 $accountInf = [$sec-&gt;userName_sc, $sec-&gt;password_sc];
 // this is mail data to send a mail
 $emailData = ['getEmail' =&gt; $getEmail, 'toMail' =&gt; $email, 'fullName' =&gt; $fullName, 'link' =&gt; $setLink, 'accountInf' =&gt; $accountInf];
 // mail sender class
 $emailClass = new SendMail;
 $sendResult = $emailClass-&gt;send_mail($emailData);
 // check, mail send is success
 if (isset($sendResult) &amp;&amp; intval($sendResult) === 1) {
 $sec = $this-&gt;checker-&gt;secureInfoProcess($sec);
 $id = $getAccount['id'];
 array_push($sec, [$sec_one, $sec_two]);
 $upd = ['userInfo_sc' =&gt; json_encode($sec)];
 $edit = $this-&gt;db-&gt;updateAction('fms_admin', $upd, ['id' =&gt; $id]);
 if (isset($edit)) {
 $_SESSION['emailSend'] = $email;
 return $this-&gt;checker-&gt;redirect('login');
 } else {
 $_SESSION['actionfaild'] = 3;
 return $this-&gt;checker-&gt;redirect('forgotPassword');
 } else {
 $_SESSION['actionfaild'] = 2;
 return $this-&gt;checker-&gt;redirect('forgotPassword');
 // user account reset
 public function resetPassword($updateUser = null)
 if (isset($_SESSION['userInformetion'])) {
 $info = $_SESSION['userInformetion'];
 $ridirectLink = $_SESSION['ridirect_l'];
 $protocol = isset($_SERVER['HTTPS']) &amp;&amp; !empty($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : 'http';
 $ridirectLink = $protocol . '://' . $_SERVER['HTTP_HOST'] . $ridirectLink;
 if (empty($_POST['passworda']) || empty($_POST['passwordr'])) {
 $_SESSION['emptyField'] = 1;
 return header('Location: ' . $ridirectLink);
 } else {
 if ($_POST['passworda'] === $_POST['passwordr']) {
 $pas = $this-&gt;checker-&gt;c_valid($_POST['passworda']);
 $secure = json_decode($info['userInfo_sc']);
 $secure_od = $secure;
 $secure = $secure-&gt;oldPassword_sc;
 if (empty($secure)) {
 $password = $pas;
 } else {
 if (in_array($pas, $secure) || $pas === $secure_od-&gt;password_sc) {
 $_SESSION['old_p'] = 1;
 return header('Location: ' . $ridirectLink);
 } else {
 $password = $pas;
 if (isset($password)) {
 $getEmail = $this-&gt;db-&gt;get_row("company_settings");
 $email = !isset($updateUser) ? $info['email'] : $this-&gt;checker-&gt;c_valid($_POST['email']);
 $newPassword = $password;
 $fullName = !isset($updateUser) ? $info['fullName'] : $this-&gt;checker-&gt;c_valid($_POST['fn']) . ' ' . $this-&gt;checker-&gt;c_valid($_POST['ln']);
 $userName = !isset($updateUser) ? $secure_od-&gt;userName_sc : $updateUser;
 $accountInf = [$userName, $newPassword];
 $emailData = ['getEmail' =&gt; $getEmail, 'toMail' =&gt; $email, 'fullName' =&gt; $fullName, 'accountInf' =&gt; $accountInf];
 // mail sender class
 $emailClass = new SendMail;
 $sendResult = $emailClass-&gt;send_mail($emailData);
 if (isset($sendResult) &amp;&amp; intval($sendResult) === 1) {
 $password = password_hash($password, PASSWORD_BCRYPT, ["cost" =&gt; 12]);
 $password_sc = $newPassword;
 $oldPassword_sc = $secure_od-&gt;oldPassword_sc;
 array_push($oldPassword_sc, $secure_od-&gt;password_sc);
 $new_userInfo_sc = ['userName_sc' =&gt; $userName, 'password_sc' =&gt; $password_sc, 'oldPassword_sc' =&gt; $oldPassword_sc];
 $upd = ['password' =&gt; $password, 'userInfo_sc' =&gt; json_encode($new_userInfo_sc)];
 unset($_SESSION['ridirect_l']);
 unset($_SESSION['userInformetion']);
 if (isset($updateUser)) {
 return $upd;
 } else {
 $passwordUpdate = $this-&gt;db-&gt;updateAction('fms_admin', $upd, ['id' =&gt; $info['id']]);
 if (isset($passwordUpdate)) {
 $_SESSION['resetSuccess'] = $email;
 return $this-&gt;checker-&gt;redirect('login');
 } else {
 $_SESSION['doesNot_m'] = 1;
 return header('Location: ' . $ridirectLink);
 // create user account
 public function createUserNamePassword($securAction = null)
 if (isset($securAction) &amp;&amp; $securAction === 8994723402 &amp;&amp; !empty($_POST)) {
 $info = $_SESSION['userinfo'];
 $userName = $this-&gt;checker-&gt;c_valid($_POST['userName']);
 $password = $this-&gt;checker-&gt;c_valid($_POST['password']);
 $userInfo_sc = json_encode(array('userName_sc' =&gt; $userName, 'password_sc' =&gt; $password, 'oldPassword_sc' =&gt; []));
 if (ctype_alnum($userName)) {
 $email = $info['email'];
 $fullName = $info['fullName'];
 $accountInf = [$userName, $password];
 $getEmail = $this-&gt;db-&gt;get_row("company_settings");
 $emailData = ['getEmail' =&gt; $getEmail, 'toMail' =&gt; $email, 'fullName' =&gt; $fullName, 'accountInf' =&gt; $accountInf];
 // mail sender class
 $emailClass = new SendMail;
 $sendResult = $emailClass-&gt;send_mail($emailData);
 if (isset($sendResult) &amp;&amp; intval($sendResult) === 1) {
 $userName = md5(sha1($userName));
 $password = password_hash($password, PASSWORD_BCRYPT, ["cost" =&gt; 12]);
 $upData = [
 'userName' =&gt; $userName,
 'password' =&gt; $password,
 'userInfo_sc' =&gt; $userInfo_sc
 $success = $this-&gt;db-&gt;updateAction('fms_admin', $upData, ['id' =&gt; $info['id']]);
 if (isset($success)) {
 unset($_SESSION['userinfo']);
 $_SESSION['a_create_success'] = $email;
 return $this-&gt;checker-&gt;redirect('login');
 } else {
 return $this-&gt;checker-&gt;redirect('setUserNamePassword');
 // user informetion add or eidt manager
 function manageUsers()
 if (isset($_SESSION['ridirect_l'])) {
 $ridirectLink = $_SESSION['ridirect_l'];
 $protocol = isset($_SERVER['HTTPS']) &amp;&amp; !empty($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : 'http';
 $ridirectLink = $protocol . '://' . $_SERVER['HTTP_HOST'] . $ridirectLink;
 if (isset($_POST['fn']) &amp;&amp; filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
 $fullName = $this-&gt;checker-&gt;c_valid($_POST['fn']) . ' ' . $this-&gt;checker-&gt;c_valid($_POST['ln']);
 $currency = isset($_POST['currency']) ? $_POST['currency'] : ";
 $percentage = $this-&gt;checker-&gt;c_valid($_POST['percentage']);
 $birthday = $this-&gt;checker-&gt;c_valid($_POST['birthday']);
 $email = $this-&gt;checker-&gt;c_valid($_POST['email']);
 $gender = $this-&gt;checker-&gt;c_valid($_POST['gender']);
 $userRoll = $this-&gt;checker-&gt;c_valid($_POST['userRoll']);
 $file_name = ";
 if (!empty($_FILES['img']['name'])) {
 $photo_array = $_FILES['img'];
 $name = explode('.', $photo_array['name']);
 $file_name = md5(rand() . time()) . '.' . end($name);
 if (isset($_POST['register']) || isset($_POST['atFirstRegisterUser'])) {
 $userName = md5(sha1($email . rand()));
 $password = md5(sha1($email . rand() . $fullName));
 $setLink = $this-&gt;checker-&gt;base_url() . 'setUserNamePassword.php?' . $userName . '=' . $password;
 $getEmail = $this-&gt;db-&gt;get_row("company_settings");
 $emailData = ['getEmail' =&gt; $getEmail, 'toMail' =&gt; $email, 'fullName' =&gt; $fullName, 'link' =&gt; $setLink];
 $emailClass = new SendMail;
 $sendResult = $emailClass-&gt;send_mail($emailData);
 if (isset($sendResult) &amp;&amp; intval($sendResult) === 1) {
 $insertD = ['fullName' =&gt; $fullName, 'email' =&gt; $email, 'userName' =&gt; $userName, 'password' =&gt; $password, 'userInfo_sc' =&gt; ", 'percentage' =&gt; $percentage, 'photo' =&gt; $file_name, 'birthday' =&gt; $birthday, 'gender' =&gt; $gender, 'userRoll' =&gt; $userRoll, 'a_date' =&gt; $this-&gt;theDay, 'u_date' =&gt; "];
 $insertSuccess = $this-&gt;db-&gt;insertAction('fms_admin', $insertD);
 if (isset($insertSuccess)) {
 $_SESSION['install'] = 1;
 $_SESSION['registerSuccess'] = $email;
 move_uploaded_file($photo_array['tmp_name'], 'uploadFiles/userPhoto/' . $file_name);
 $page = isset($_POST['register']) ? 'userRegistration' : 'login';
 return $this-&gt;checker-&gt;redirect($page);
 } else {
 $_SESSION['sorry'] = 'action failde';
 return $this-&gt;checker-&gt;redirect('userRegistration');
 } else {
 $exists_p = $this-&gt;db-&gt;get("fms_admin");
 if (isset($exists_p)) {
 return $this-&gt;checker-&gt;redirect('userRegistration');
 return $this-&gt;checker-&gt;redirect('registerPartner');
 if (isset($_POST['editUserInfo'])) {
 $preEdit = $_SESSION['userInformetion'];
 $upFile = empty($_FILES['img']['name']) ? $preEdit['photo'] : $file_name;
 $upd = ['fullName' =&gt; $fullName, 'email' =&gt; $email, 'percentage' =&gt; $percentage, 'photo' =&gt; $upFile, 'birthday' =&gt; $birthday, 'gender' =&gt; $gender, 'userRoll' =&gt; $userRoll, 'u_date' =&gt; $this-&gt;theDay];
 if (isset($_POST['passworda']) &amp;&amp; !password_verify($_POST['passworda'], $preEdit['password'])) {
 $userName = $this-&gt;checker-&gt;c_valid($_POST['userName']);
 $updatePass = $this-&gt;resetPassword($userName);
 if (is_array($updatePass) &amp;&amp; !empty($updatePass)) {
 $resetSuccess = 1;
 $upd['userName'] = md5(sha1($userName));
 $upd['password'] = $updatePass['password'];
 $upd['userInfo_sc'] = $updatePass['userInfo_sc'];
 } else {
 return header('Location: ' . $ridirectLink);
 } elseif (isset($_POST['userName'])) {
 $userName = $this-&gt;checker-&gt;c_valid($_POST['userName']);
 $upd['userName'] = md5(sha1($userName));
 $id = $preEdit['id'];
 $edit = $this-&gt;db-&gt;updateAction('fms_admin', $upd, ['id' =&gt; $id]);
 if (isset($edit)) {
 $_SESSION['editSuccess'] = 1;
 isset($resetSuccess) ? $_SESSION['resetSuccess'] = $email : false;
 $user = $this-&gt;db-&gt;get_row('fms_admin', ['id' =&gt; $id]);
 unset($user['password']);
 unset($user['userName']);
 unset($user['userInfo_sc']);
 $_SESSION['userinfo']['id'] === $id ? $_SESSION['userinfo'] = $user : false;
 if ($upFile === $file_name) {
 move_uploaded_file($photo_array['tmp_name'], 'uploadFiles/userPhoto/' . $upFile);
 unlink('uploadFiles/userPhoto/' . $preEdit['photo']);
 return $this-&gt;checker-&gt;redirect('users');
 } else {
 $_SESSION['editfaild'] = 1;
 } else {
 $_SESSION['invalidEmail'] = $_POST['email'];
 if (isset($_POST['editUserInfo'])) {
 return header('Location: ' . $ridirectLink);
 } else {
 return $this-&gt;checker-&gt;redirect('userRegistration');
 // add user Earns
 public function cashInsert()
 $source = $this-&gt;checker-&gt;c_valid($_POST['source']);
 $amount = $this-&gt;checker-&gt;c_valid($_POST['amount']);
 if (ctype_digit($amount)) {
 $id = $_SESSION['userinfo']['id'];
 $insertData = ['id' =&gt; $id, 'earnSource' =&gt; $source, 'amount' =&gt; $amount, 'currency' =&gt; ", 'ba_date' =&gt; $this-&gt;theDay, 'bu_date' =&gt; "];
 $result = $this-&gt;db-&gt;insertAction('fms_bank', $insertData);
 if (isset($result)) {
 $_SESSION['success_ms'] = 1;
 return $this-&gt;checker-&gt;redirect('bankCash');
 } else {
 $_SESSION['invalidAmount'] = $amount;
 return $this-&gt;checker-&gt;redirect('bankCash');
 // edit user Earns
 public function cashUpdate()
 $source = $this-&gt;checker-&gt;c_valid($_POST['source']);
 $bankId = $this-&gt;checker-&gt;c_valid($_POST['updateId']);
 $amount = $this-&gt;checker-&gt;c_valid($_POST['amount']);
 if (!empty($bankId)) {
 $up_data = ['earnSource' =&gt; $source, 'amount' =&gt; $amount, 'bu_date' =&gt; $this-&gt;theDay];
 $result = $this-&gt;db-&gt;updateAction('fms_bank', $up_data, ['bankId' =&gt; $bankId]);
 if (isset($result)) {
 $_SESSION['info_message'] = 1;
 return $this-&gt;checker-&gt;redirect('cashDetails');
 // Expense maange add or eidt
 public function manageExpense()
 $amount = $this-&gt;checker-&gt;c_valid($_POST['amount']);
 if (isset($_SESSION['costInsert'])) {
 $memoData = [];
 $memoName = $_FILES['memo']['name'];
 $tmpName = $_FILES['memo']['tmp_name'];
 for ($i = 0; $i &lt; count($memoName); $i++) {
 $memoName[$i];
 $tmpName[$i];
 if (!empty($memoName[$i])) {
 $name = explode('.', $memoName[$i]);
 $fileName = md5(rand() . $name[0] . time()) . '.' . end($name);
 $memoData[] = $fileName;
 move_uploaded_file($tmpName[$i], 'uploadFiles/memo/' . $fileName);
 } else {
 $memoData[] = ";
 $id = $_SESSION['userinfo']['id'];
 $costDetails = json_encode(['c_productName' =&gt; $_POST['costCn'], 'c_amount' =&gt; $_POST['costCa'], 'c_memo' =&gt; $memoData]);
 $insertData = ['id' =&gt; $id, 'cst_amount' =&gt; $amount, 'cst_currency' =&gt; ", 'cost_details' =&gt; $costDetails, 'cst_a_date' =&gt; $this-&gt;theDay, 'cst_u_date' =&gt; "];
 $result = $this-&gt;db-&gt;insertAction('fms_cost', $insertData);
 if (isset($result)) {
 $_SESSION['info_message'] = 'submited';
 return $this-&gt;checker-&gt;redirect('costManage');
 if (isset($_SESSION['costEdit'])) {
 $memoData = [];
 $upId = $_SESSION['costEdit'];
 $memoName = $_FILES['memo']['name'];
 $tmpName = $_FILES['memo']['tmp_name'];
 $preEdit = $this-&gt;db-&gt;get_row('fms_cost', ['cst_id' =&gt; $upId]);
 $oldMemo = json_decode($preEdit['cost_details']);
 $upc_memo = isset($oldMemo-&gt;c_memo) ? $oldMemo-&gt;c_memo : [];
 for ($i = 0; $i &lt; count($memoName); $i++) {
 $memoName[$i];
 $tmpName[$i];
 if (!empty($memoName[$i])) {
 $name = explode('.', $memoName[$i]);
 $fileName = md5(rand() . $name[0] . time()) . '.' . end($name);
 $memoData[] = $fileName;
 isset($upc_memo[$i]) ? unlink('uploadFiles/memo/' . $upc_memo[$i]) : false;
 move_uploaded_file($tmpName[$i], 'uploadFiles/memo/' . $fileName);
 } else {
 $memoData[] = isset($upc_memo[$i]) ? $upc_memo[$i] : ";
 $costDetails = json_encode(['c_productName' =&gt; $_POST['costCn'], 'c_amount' =&gt; $_POST['costCa'], 'c_memo' =&gt; $memoData]);
 $upData = ['id' =&gt; $preEdit['id'], 'cst_amount' =&gt; $amount, 'cost_details' =&gt; $costDetails, 'cst_u_date' =&gt; $this-&gt;theDay];
 $updateSuccess = $this-&gt;db-&gt;updateAction('fms_cost', $upData, ['cst_id' =&gt; $upId]);
 if (isset($updateSuccess)) {
 unset($_SESSION['costEdit']);
 if ($upFile === $cst_memo) {
 move_uploaded_file($photo_array['tmp_name'], 'uploadFiles/memo/' . $upFile);
 !empty($preEdit['cst_memo']) ? unlink('uploadFiles/memo/' . $preEdit['cst_memo']) : false;
 $_SESSION['info_message'] = ' update ' . $cst_memo_up;
 return $this-&gt;checker-&gt;redirect('userCostDetails');
$action = new Action;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
 if (isset($_SESSION['atFirstSettings'])) {
 return $action-&gt;manageSettings(0000010113112);
 } elseif (isset($_SESSION['registerPartner'])) {
 unset($_SESSION['registerPartner']);
 return $action-&gt;manageUsers();
 } elseif (isset($_SESSION['userinfo'])) {
 $userInfo = $_SESSION['userinfo'];
 if (isset($_SESSION['createUserNamePassword'])) {
 unset($_SESSION['createUserNamePassword']);
 return $action-&gt;createUserNamePassword(0103010113112);
 if (isset($_POST['getBy']) &amp;&amp; !empty($_POST['getBy'])) {
 $getBy = $action-&gt;checker-&gt;c_valid($_POST['getBy']);
 if ($getBy === '101' || $getBy === '010') {
 return $action-&gt;getAccount($getBy);
 if (isset($_SESSION['resetAccount404'])) {
 return $action-&gt;resetAccount(0103010112);
 if (isset($_SESSION['csrf']) &amp;&amp; $_SESSION['csrf'] === $_POST['cc']) {
 unset($_SESSION['csrf']);
 return $action-&gt;resetPassword();
 // sec_a = secure action
 if (isset($_SESSION['sec_a'], $_POST['sec_a']) &amp;&amp; $_SESSION['sec_a'] === $_POST['sec_a']) {
 if ($_POST['settingsEdit']) {
 return $action-&gt;manageSettings(0000010113112);
 if (isset($_POST['updateEmail'])) {
 return $action-&gt;updateEmail();
 if (isset($_SESSION['bank'])) {
 unset($_SESSION['bank']);
 if (isset($_SESSION['cashInsert'])) {
 unset($_SESSION['cashInsert']);
 return $action-&gt;cashInsert();
 if (isset($_SESSION['cashUpdate'])) {
 unset($_SESSION['cashUpdate']);
 return $action-&gt;cashUpdate();
 if (isset($_SESSION['userAction'])) {
 unset($_SESSION['userAction']);
 return $action-&gt;manageUsers();
 if (isset($_SESSION['costAction'])) {
 unset($_SESSION['costAction']);
 return $action-&gt;manageExpense();
 return $action-&gt;checker-&gt;redirect('404');
 } else {
 return $action-&gt;checker-&gt;redirect('login');
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET' &amp;&amp; isset($_SESSION['userinfo']) &amp;&amp; isset($_SESSION['sec_a']) &amp;&amp; isset($_GET) &amp;&amp; !empty($_GET)) {
 $userInfo = $_SESSION['userinfo'];
 $valueId = array_values($_GET);
 $keysId = array_keys($_GET);
 // to delete Earn row
 if (isset($_SESSION['bank']) &amp;&amp; $_SESSION['sec_a'] === $valueId[1]) {
 $id = $action-&gt;checker-&gt;makeId($valueId[0]);
 $pre_delete = $action-&gt;db-&gt;get_row('fms_bank', ['bankId' =&gt; $id]);
 $delete = $action-&gt;db-&gt;deleteAction('fms_bank', ['bankId' =&gt; $id]);
 if (isset($delete)) {
 $currency = $pre_delete["currency"] === 'bdt' ? 'Tk' : '$';
 $_SESSION['info_message'] = [($pre_delete["bankId"]), ($pre_delete["amount"] . $currency)];
 return $action-&gt;checker-&gt;redirect('cashDetails');
 // to delete user
 if (isset($_SESSION['user']) &amp;&amp; $_SESSION['sec_a'] === $keysId[0]) {
 $id = $action-&gt;checker-&gt;makeId($valueId[0]); // make user id
 $user = $action-&gt;db-&gt;get_row('fms_admin', ['id' =&gt; $id]); // user information
 $deleteSucccess = $action-&gt;db-&gt;deleteAction('fms_admin', ['id' =&gt; $id]);
 if (isset($deleteSucccess)) {
 unlink('uploadFiles/userPhoto/' . $user['photo']);
 if ($userInfo['id'] === $id) {
 return $action-&gt;checker-&gt;redirect('login');
 } else {
 $_SESSION['deleteSucccess'] = $user['fullName'];
 return $action-&gt;checker-&gt;redirect('users');
 return $action-&gt;checker-&gt;redirect('404');
} else {
 return $action-&gt;checker-&gt;redirect('404');
PHP Syntax.
Request Vars.
Although our servers currently have register_globals enabled, PHP 6 will remove this option. Therefore, in new code, you should always use the super globals $_GET, $_POST, and $_COOKIE. $_REQUEST should be used only when it is known for sure that a variable could be supplied using multiple methods. 
PHP &amp; HTML.
No "template system" such as Smarty will be used. PHP itself is a templating language. A best effort should be made to arrange your code by putting logic at the top of file and output at the bottom of the file. Sometimes that will require looping the same information twice. However, this will make the code much more maintainable.
Control Structures.
These include if, for, while, switch, etc. 
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.
You are strongly encouraged to always use curly braces even in situations where they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.
Function Calls.
Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; spaces between commas and each
parameter, and no space between the last parameter, the closing parenthesis, and the semicolon.
As displayed above, there should be one space on either side of an equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, more space may be inserted to promote readability:
Function Definitions.
Function declarations are similar to function calls with the beginning brace on the same line as the function declaration.
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate.
Comments.
Complete inline documentation comment blocks (docblocks) must be provided. Please read the Sample File and Header Comment Blocks sections to learn the specifics of writing docblocks for PHP. Further information can be found on the 
phpDocumentor website.
Non-documentation comments are strongly encouraged. A rule of thumb is that if you look at a section of code and think "Wow, I don't want to try and describe that", you need to comment it before you forget how it works.
C style comments (/* */) and standard C++ comments (//) are both fine. The use of Perl / shell style comments (#) is "strongly" discouraged.
Including Code.
Anywhere you are unconditionally including a class file, use require_once. Anywhere you are conditionally including a class file, use include_once. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with require_once will not be included again by include_once.
PHP Code Tags.
Always use &lt;?php ?&gt; to delimit PHP code, not the &lt;? ?&gt; shorthand. This is the most portable way to include PHP code on different operating systems and server setups.
Header Comment Blocks.
All source code files shall contain a "page-level" docblock at the top of each file and a "class-level" docblock immediately above each class or function.
Required Tags That Have Variable Content.
Short Descriptions.
Short descriptions must be provided for all docblocks. They should be a quick sentence, not the name of the item. Please read the Coding Standard's Sample File about how to write good descriptions.
@author.
There's no hard rule to determine when a new code contributor should be added to the list of authors for a given source file. In general, their changes should fall into the "substantial" category (meaning somewhere around 10% to 20% of code changes). Exceptions could be made for rewriting functions or contributing new logic.
Simple code reorganization or bug fixes would not justify the addition of a new individual to the list of authors.
@since.
This tag is required when a file or class is added after the package's initial release. Do not use it in an initial release.
@deprecated.
This tag is required when a file or class is no longer used but has been left in place for backwards compatibility.
Order and Spacing.
To ease long-term readability of the source code, the text and tags must conform to the order and spacing provided in the example above. This standard is adopted from the JavaDoc standard.
Example URLs.
Use example.com, example.org and example.net for all example URLs and email addresses, per RFC 2606.
Naming Conventions.
Classes.
Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter and use mixed case to separate "words".
Examples of good class names are:
Functions, Methods and Variable Names.
Functions, methods and variable names should be named using the Unix C style. If applicable, functions should have the package or library name as a prefix to avoid name collisions. Names should be all lowercase with each new "word" separated by an underscore(_). Some examples:
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared are preceded by a single underscore. For example:
Constants and Global Variables.
Constants and global variables should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercased name of the class/package they are used in. For example, the constants used by a package named DB begin with DB_.
Note: The true, false and null constants are excepted from the all-uppercase rule, and must always be lowercase.
File Formats.
All scripts must:
Sample File.
Each docblock in the example contains many details about writing Docblock Comments. Following those instructions is important for two reasons. First, when docblocks are easy to read, users and developers can quickly ascertain what your code does. 
Please take note of the vertical and horizontal spacing. They are part of the standard.