Jump to content

davidolson

Members
  • Posts

    37
  • Joined

  • Last visited

davidolson's Achievements

Member

Member (2/5)

0

Reputation

  1. WOKRKING QUERY $status = array_map('strval', $var['receiver']); $statusSql = implode('","', $status); $query = 'SELECT email FROM users WHERE status IN("'.$statusSql.'")'; $select = $db->query($query);
  2. Tried this way and it is working $query = 'SELECT email FROM users WHERE status IN("active", "inactive", "un-verified", "cheater")'; $select = $db->query($query);
  3. If i check more than one checkbox. I dont get any value from database. HTML <form method="post"> <input type="checkbox" name="receiver[]" value="cheater">CHEATER <input type="checkbox" name="receiver[]" value="un-verified">UN-VERIFIED <input type="checkbox" name="receiver[]" value="inactive">INACTIVE <input type="checkbox" name="receiver[]" value="active">ACTIVE <input type="submit" name="submit" value="ADD"> </form> PHP $errors = array(); $success = NULL; $error = NULL; $var['receiver'] = isset($_POST['receiver']) ? $_POST['receiver'] : NULL; ................. if(!empty($_POST['submit'])){ // FORM VALIDATION // } if(!empty($_POST['submit']) and empty($errors)){ $status = array_map('strval', $var['receiver']) + array(0); $statusSql = implode(',', $status); $query = 'SELECT email FROM users WHERE status IN("'.$statusSql.'")'; $select = $db->prepare($query); $select->execute(); $arrayData = array(); while($row = $select->fetch(PDO::FETCH_ASSOC)){ $arrayData[] = $row['email']; } $errors[] = implode(',', $arrayData); } require_once 'includes/antiCsrf/index.php'; $csrf = new antiCsrf(); $smarty->assign('success', $success); $smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->assign('csrfKey', $csrf->csrfKey()); $smarty->assign('csrfToken', $csrf->csrfToken()); $smarty->assign('var', $var); .................
  4. Just figured out oTable = $('.datatable table').dataTable({ "bJQueryUI": false, "bAutoWidth": false, "sPaginationType": "full_numbers", "sDom": '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>', "oLanguage": { "sSearch": "<span>Filter all:</span> _INPUT_", "sLengthMenu": "<span>Show entries:</span> _MENU_", "oPaginate": { "sFirst": "First", "sLast": "Last", "sNext": "Next", "sPrevious": "Previous" } }, "order": [], /* No initial order */ "aoColumnDefs": [ { "bSortable": false, "aTargets": ['nosort'] }, /* Colomn data not sortable. Use <th class="nosort"> */ { "bSearchable": false, "aTargets": ['nosearch'] } /* Colomn data not searchable. Use <th class="nosearch"> */ ] });
  5. How do disable searching in specific column like Action col Id--Username--Subject--Action | Do not search oTable = $('.datatable table').dataTable({ "bJQueryUI": false, "bAutoWidth": false, "sPaginationType": "full_numbers", "sDom": '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>', "oLanguage": { "sSearch": "<span>Filter all:</span> _INPUT_", "sLengthMenu": "<span>Show entries:</span> _MENU_", "oPaginate": { "sFirst": "First", "sLast": "Last", "sNext": "Next", "sPrevious": "Previous" } }, "order": [], /* No initial order */ "aoColumnDefs": [{ "bSortable": false, "aTargets": ['nosort'] /* Colomn data not sortable. Use <th class="nosort"> */ }] });
  6. Why smarty won't find my template file? Fatal error: Uncaught --> Smarty: Unable to load template file 'test.tpl' <-- thrown in C:\xampp\htdocs\testing\includes\smarty\sysplugins\smarty_internal_templatebase.php on line 129 also did testinstall $smarty->testInstall(); Smarty Installation test... Testing template directory... C:\xampp\htdocs\testing\templates\frontend\default\tpl is OK. Testing compile directory... C:\xampp\htdocs\testing\templates_c\frontend is OK. Testing plugins directory... C:\xampp\htdocs\testing\includes\smarty\plugins is OK. Testing cache directory... C:\xampp\htdocs\testing\cache is OK. Testing configs directory... C:\xampp\htdocs\testing\configs is OK. Testing sysplugin files... ... OK Testing plugin files... ... OK Tests complete. And get template dir var_dump($smarty->getTemplateDir()); array(1) { [0]=> string(55) "C:/xampp/htdocs/testing/templates/frontend/default/tpl\" } File schema htdocs -- testing -- incluses -- smarty plugins sysplugins Smarty.class.php SmartyBC.class.php -- configs configs.php -- db connect.php db.php -- configs -- cache -- templates -- frontend -- default -- css -- mages -- js -- tpl test.tpl -- backend -- templates_c -- frontend index.php index.php <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('display_startup_errors', TRUE); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); ob_start(); session_start(); require 'includes/smarty/Smarty.class.php'; require 'includes/db/db.php'; require 'includes/configs/configs.php'; $page = isset($_GET['do']) ? $_GET['do'] : ''; switch($page){ case 'home'; include 'pages/home.php'; break; default: include 'pages/test.php'; break; } ob_flush(); ?> configs.php <?php $smarty = new Smarty(); $smarty->compile_check = true; $smarty->debugging = false; $smarty->cache = 1; $smarty->setTemplateDir('C:/xampp/htdocs/testing/templates/frontend/default/tpl'); $smarty->setCompileDir('C:/xampp/htdocs/testing/templates_c/frontend/default'); $smarty->setCacheDir('C:/xampp/htdocs/testing/cache'); $smarty->setConfigDir('C:/xampp/htdocs/testing/configs'); ?> test.php <?php //$success = 'Success Message'; //$error = 'Error Message'; $errors[] = 'Error one'; $errors[] = 'Error two'; $smarty = new Smarty; //$smarty->assign('success', $success); //$smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->display('test.tpl'); ?> test.tpl {if !empty($errors)} <div id="errors"> {section name=i loop=$errors} {$errors[i]}<br /> {/section} </div> {/if}
  7. db table username------>id->username->cash->points->referrer db table referral_levels------>id->level->earnings->signupBonusCash->signupBonusPoints->status username referrer -------- -------- admin kelly88 admin // UPDATE USERNAME ADMIN WITH referral level 1 POINTS/CASH // jacob kelly88 // UPDATE USERNAME ADMIN WITH referral level 2 POINTS/CASH AND USERNAME kelly88 WITH referral level 1 POINTS/CASH // david16 jacob // UPDATE USERNAME ADMIN WITH referral level 3 POINTS/CASH AND USERNAME kelly88 WITH referral level 2 POINTS/CASH AND USERNAME jacob WITH referral level 1 POINTS/CASH // Is this possible. If yes - HOW? Current test registration code with referral level 1 <?php if(!empty($_GET['ref'])){ $referrerUsername = filter_input(INPUT_GET, 'ref', FILTER_SANITIZE_STRING); if(usernameExist($referrerUsername, $db) === TRUE){ $_SESSION['ref'] = $referrerUsername; } } // define variables with the value for each field // the value from POST,GET if this exist, or an empty value $errors = array(); $username = isset($_POST['username']) ? filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING) : ''; $referrer = !empty($_SESSION['ref']) ? $_SESSION['ref'] : (isset($_POST['referrer']) ? filter_input(INPUT_POST, 'referrer', FILTER_SANITIZE_STRING) : ''); if(!empty($_POST['submit'])){ if(empty($username)){ $errors[] = $lang['error']['a_019']; } else if(validUsernameLenght($username) === FALSE){ $errors[] = $lang['error']['a_020']; } else if(validUsernameChars($username) === FALSE){ $errors[] = $lang['error']['a_021']; } else if(usernameExist($username, $db) === TRUE){ $errors[] = $lang['error']['a_022']; } if(!empty($referrer)){ if(usernameExist($referrer, $db) === FALSE){ $errors[] = $lang['error']['a_037']; } else if($username == $referrer){ $errors[] = $lang['error']['a_038']; } } } if(!empty($_POST['submit']) and empty($errors)){ /* $queryOne = 'INSERT INTO users(username, referrer) VALUES (:username, :referrer)'; $insertOne = $db->prepare($queryOne); $insertOne->bindParam(':username', $username, PDO::PARAM_STR); $insertOne->bindParam(':referrer', $referrer, PDO::PARAM_STR); $successOne = $insertOne->execute(); */ if($referrer){ $query = 'SELECT signupBonusCash AS sbc, signupBonusPoints AS sbp FROM referral_levels WHERE level = 1 AND status = "enabled"'; $select = $db->query($query); $row = $select->fetch(PDO::FETCH_ASSOC); $queryTwo = 'UPDATE users SET points = points + :points, cash = cash + :cash WHERE username = :referrer'; $selectTwo = $db->prepare($queryTwo); $selectTwo->bindParam(':cash', $row['sbc'], PDO::PARAM_STR); $selectTwo->bindParam(':points', $row['sbp'], PDO::PARAM_STR); $selectTwo->bindParam(':referrer', $referrer, PDO::PARAM_STR); $selectTwo->execute(); } } if(!empty($errors)){ foreach($errors as $error){ print $error.'<br>'; } } print ' <form method="POST"> <table style="width:100%"> <tr> <td style="width:30%;font-weight:bold">Username</td> <td style="width:70%"><input type="text" name="username" maxlength="255" style="width:200px" value="'.cleanOutput($username).'"></td> </tr>'; if(!empty($_SESSION['ref'])){ print ' <tr> <td style="font-weight:bold">'.$lang['global']['a_047'].'</td> <td><input type="text" name="referrer" readonly="readonly" maxlength="255" style="width:200px" value="'.cleanOutput($referrer).'"></td> </tr>'; }else{ print ' <tr> <td style="font-weight:bold">'.$lang['global']['a_047'].'</td> <td><input type="text" name="referrer" maxlength="255" style="width:200px" value="'.cleanOutput($referrer).'"></td> </tr>'; } print ' <tr> <td colspan="2" style="text-align:center"><input type="submit" name="submit" value="Submit"></td> </tr> </table> </form>'; ?>
  8. db SCHEMA happening_now ------->id->message->dateCreated function insertHappening($message, $date, $db){ $query = 'INSERT INTO happening_now (message, dateCreated) VALUES (:message, :dateCreated)'; $insert = $db->prepare($query); $insert->bindValue(':message', $message, PDO::PARAM_STR); $insert->bindParam(':dateCreated', $date, PDO::PARAM_INT); $success = $insert->execute(); if($success){ return TRUE; } return FALSE; } function showHappening($db, $limit = 20){ $query = 'SELECT * FROM happening_now ORDER BY dateCreated DESC LIMIT :limit'; $select = $db->prepare($query); $select->bindParam(':limit', $limit, PDO::PARAM_INT); $select->execute(); if(!empty($select->rowCount())){ while($row = $select->fetch(PDO::FETCH_ASSOC)){ print ' <div>'.timeAgo('@'.$row['dateCreated']).' - '.$row['message'].'</div><br>'; } } } function timeAgo($dateFrom, $dateTo = NULL){ $dateStart = date_create($dateFrom); if($dateTo === NULL){ $dateEnd = date_create(NULL); }else{ $dateEnd = date_create($dateTo); } $interval = date_diff($dateStart, $dateEnd); $doPlural = function($nb, $str){return $nb > '1' ? $str.'s' :$str;}; // adds plurals $format = array(); if($interval->y !== 0){ $format[] = '%y '.$doPlural($interval->y, 'year'); } if($interval->m !== 0){ $format[] = '%m '.$doPlural($interval->m, 'month'); } if($interval->d !== 0){ $format[] = '%d '.$doPlural($interval->d, 'day'); } if($interval->h !== 0){ $format[] = '%h '.$doPlural($interval->h, 'hour'); } if($interval->i !== 0){ $format[] = '%i '.$doPlural($interval->i, 'minute'); } if($interval->s !== 0){ $format[] = '%s '.$doPlural($interval->s, 'second'); } if(count($format) > 1){ $format = array_shift($format).' and '.array_shift($format); }else{ $format = array_pop($format); } return $interval->format( $format.' ago'); } $username = 'KELLY'; $offerName = 'Crowd Flower'; $amount = '30'; $currency = 'points'; $lang['text']['a_001'] = '%a has just completed the %b offer worth %c %d.';// language/english/user.php // insertHappening(str_replace(array('%a','%b','%c','%d'), array($username, $offerName, $amount, $currency), $lang['text']['a_001']), createUnixTimestamp($configs), $db); showHappening($db, 15);// Show output based on user selected language // // OUTPUT // //46 minutes ago - KELLY has just joined our community. //19 minutes and 5 seconds ago - KELLY has just completed the Crowd Flower offer worth 30 points.
  9. How should i input language file into db and then output it with user selected language? $username = 'KELLY'; $offerName = 'Crowd Flower'; $amount = '30'; $currency = 'points'; $lang['text']['a_001'] = '%a has just completed the %b offer worth %c %d.';// ENGLISH // $input = str_replace(array('%a','%b','%c','%d'), array($username, $offerName, $amount, $currency), $lang['text']['a_001']); print $input;
  10. my browser crash when i try to search items
  11. <script type="text/javascript"> function listBoxSearch(){ var input = document.getElementById('searchBox'), output = document.getElementById('listBoxF'); if(input.value != ''){ for (var i = 0; i < output.options.length; i++){ if(output.options[i].text.substring(0, input.value.length).toUpperCase() == input.value.toUpperCase()){ output.options[output.options.length] = new Option(output.options[i].innerHTML, output.options[i].text); } } if (output.options.length == 1) { output.selectedIndex = 0; } } } </script> It dosen`t work. It should work like this[DEMO in attached filed] listbox_with_keybord_search.htm
  12. current DB schema instant_gift_cards => id -> giftCardName -> giftCardImage -> dateCreated -> status instant_gift_card_codes => id -> giftCardId -> currency -> amount -> pointsPrice -> giftCardCode -> cardWinner -> dateCreated -> dateRequested -> status
  13. How to display items like bottom table? And here is the code <? print" <table style=\"width:100%\" class=\"tableList\"> <tr> <th style=\"width:35%\">Prize Name</th> <th style=\"width:12%\">Amount</th> <th style=\"width:12%\">Points</th> <th style=\"width:12%\">Available</th> <th style=\"width:12%\">Redeemed</th> <th style=\"width:17%\">Action</th> </tr>"; $giftCardQuery = 'SELECT currency, amount, pointsPrice, instant_gift_cards.id, instant_gift_cards.giftCardName, instant_gift_cards.giftCardImage FROM instant_gift_card_codes INNER JOIN instant_gift_cards ON (instant_gift_card_codes.giftCardId = instant_gift_cards.id) WHERE instant_gift_cards.status = :cardStatus ORDER BY instant_gift_cards.dateCreated DESC'; $giftCard = $db->prepare($giftCardQuery); $giftCard->bindValue(':cardStatus', 'Enabled', PDO::PARAM_STR); $giftCard->execute(); if($giftCard->rowCount() > '0'){ while($giftCardRow = $giftCard->fetch(PDO::FETCH_ASSOC)){ $giftCardsAvailableQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsAvailable = $db->prepare($giftCardsAvailableQuery); $giftCardsAvailable->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsAvailable->bindValue(':status', 'Available', PDO::PARAM_STR); $giftCardsAvailable->execute(); $gCardsAvailable = $giftCardsAvailable->fetch(PDO::FETCH_COLUMN); $giftCardsRedeemedQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsRedeemed = $db->prepare($giftCardsRedeemedQuery); $giftCardsRedeemed->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsRedeemed->bindValue(':status', 'Redeemed', PDO::PARAM_STR); $giftCardsRedeemed->execute(); $gCardsRedeemed = $giftCardsRedeemed->fetch(PDO::FETCH_COLUMN); if($giftCardRow['giftCardImage']){ $nameOrImage = '<img src="./images/giftcardrewards/'.$giftCardRow['giftCardImage'].'" alt="'.$giftCardRow['giftCardName'].'" title="'.$giftCardRow['giftCardName'].'">'; }else{ $nameOrImage = $giftCardRow['giftCardName']; } if($gCardsAvailable == '0'){ $redeemAction = 'Out of Stock'; } elseif($userInfo['currentPoints'] < $giftCardRow['pointsPrice']){ $needed = $giftCardRow['pointsPrice'] - $userInfo['currentPoints']; $redeemAction = 'You need '.$needed.' point(s)'; } elseif($userInfo['currentPoints'] >= $giftCardRow['pointsPrice']){ $redeemAction = '<input type="button" value="Redeem" onclick="if(confirm(\'Are you sure to redeem this prize?\')){location.href=\'index.php?do=instantGiftCards&action=redeem&cardId='.$giftCardRow['id'].'&amount='.$giftCardRow['amount'].'\';}">'; } print" <tr> <td>".$nameOrImage."</td> <td style=\"text-align:center\">".$giftCardRow['currency'].$giftCardRow['amount']."</td> <td style=\"text-align:center\">".$giftCardRow['pointsPrice']."</td> <td style=\"text-align:center\">".$gCardsAvailable."</td> <td style=\"text-align:center\">".$gCardsRedeemed."</td> <td style=\"text-align:center\">".$redeemAction."</td> </tr>"; } }else{ print" <tr> <td colspan=\"4\" style=\"text-align:center;color:#2B1B17;padding:15px 0\">No prizes added.</td> </tr>"; } print" </table>"; ?>
  14. <?php global $db, $configs, $userInfo; function get_checked($variable, $status){ if($variable == $status){ return 'checked="checked"'; }else{ return ''; } } if(isset($_GET['action']) and $_GET['action'] == 'editEmailAlerts'){ $emailNewsletter = isset($_POST['emailNewsletter']) ? filter_input(INPUT_POST, 'emailNewsletter') : 'No'; $emailInbox = isset($_POST['emailInbox']) ? filter_input(INPUT_POST, 'emailInbox') : 'No'; if(!empty($_POST['submit'])){ $updateUserQuery = 'UPDATE users SET emailNewsletter = :emailNewsletter, emailInbox = :emailInbox WHERE username = :username'; $updateUser = $db->prepare($updateUserQuery); $updateUser->bindParam(':emailNewsletter', $emailNewsletter, PDO::PARAM_STR); $updateUser->bindParam(':emailInbox', $emailInbox, PDO::PARAM_STR); $updateUser->bindParam(':username', $userInfo['username'], PDO::PARAM_STR); $updateUserSuccess = $updateUser->execute(); if($updateUserSuccess){ $successMessage = $lang['success']['emailAlertsHasBeenEdited']; }else{ $errorMessage = $lang['error']['databaseError']; } } if($configs['showPageName'] == 'Yes'){ print" <div class=\"pageName\">{$lang['global']['page']} ⇒ {$lang['global']['changeEmailAlerts']}</div>"; } if(!empty($successMessage)){ print" <div class=\"successMsgBox\"> <div class=\"title\">{$lang['success']['successMessage']}</div> <div class=\"text\">{$successMessage}</div> </div>"; } if(!empty($errorMessage)){ print" <div class=\"errorMsgBox\"> <div class=\"title\">{$lang['error']['errorMessage']}</div> <div class=\"text\">{$errorMessage}</div> </div>"; } print" <form action=\"\" method=\"POST\"> <table style=\"width:100%\" class=\"defaultTable\"> <tr> <td style=\"width:30%;font-weight:bold\">{$lang['global']['emailNewsletter']}</td> <td style=\"width:70%\"><input type=\"checkbox\" name=\"emailNewsletter\" value=\"Yes\" ".get_checked($emailNewsletter, 'Yes')."></td> </tr> <tr> <td style=\"font-weight:bold\">{$lang['global']['emailInbox']}</td> <td><input type=\"checkbox\" name=\"emailInbox\" value=\"Yes\" ".get_checked($emailInbox, 'Yes')."</td> </tr> <tr> <td colspan=\"2\" style=\"text-align:center\"><input type=\"submit\" name=\"submit\" class=\"button\" value=\"{$lang['button']['editEmailAlerts']}\"></td> </tr> </table> </form>"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.