function addOTPatRegister($otpNum, $regId, $otpCount) { $dbObj = new InteractDatabase(); $acc = new UserAccounts(); // Check Already Registration Number exist or not $result = $acc->checkRegIDExist($regId); if ($result == 'NotExist' && $regId != 0) { $sql = "INSERT INTO `userlogin`(`idUserRegistration`, `OTPCode`, `OTPCount`) VALUES (" . $regId . ",'" . $otpNum . "','" . $otpCount . "')"; $dbObj->addupdateData($sql); } else { // Get OTPCount $gsql = "SELECT OTPCount FROM `userlogin` WHERE `idUserRegistration`=" . $regId; $json = $dbObj->getJSONData($gsql); $dejson = json_decode($json); $otpcount = $dejson[0]->{'OTPCount'}; $otpcount++; $usql = "UPDATE `userlogin` SET `OTPCode`='" . $otpcount . "', `OTPCode`='" . $otpNum . "' WHERE `idUserRegistration`=" . $regId; $dbObj->addupdateData($usql); } }