Jump to content

nankoweap

Members
  • Posts

    113
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

nankoweap's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. how about something like: <?php // assuming you can get your values into an array $a = array('1','2','3','4','5','6'); $count = count($a); $result = ''; for ($i=0; $i < $count-1; $i++) { $result .= $a[$i] . ', '; } $result = trim($result, ', '); print "$result and " . $a[$count-1] . "\n"; ?> some error checking in the obvious places is warranted, but this is a relatively basic approach to the problem.
  2. certainly not a php coding issue, but an html issue. try the "align" attribute of the paragraph tag... <p align='left'> this is to the left </p> <p align="right"> this is to the right </p> if you need to get fancier, brush up on css and tables as blueskyis mentioned.
  3. assuming the column is a number, you could do it in the sql. select col as kb, col/1024 as mb, col/(1024 * 1024) as gb from ... probably some formatting sql functions too, but you could do it php if needed.
  4. there's probably an easier way to do this, but you use the concat function in your sql statement to get this done.
  5. true dat. for some sites this doesn't matter as much and restrictions may be loosened. for my site and the security of my users i choose to err on the side of inconvenience when it comes to security. users share in the responsibility as well. for instance, i keep users logged in for up to 30 minutes between requests rather than making them log in with each secure request. but even with a 30 minute limit, the application doesn't know if the user logged in, did what they wanted, didn't bother to log out and someone else is at the helm.
  6. or rather... $db->select('member', '*', array('id' => $_POST['id']));
  7. try this... $db->select('member', '*', 'id = ' . $_POST['id']);
  8. i don't know how other sites do it and i haven't given this much thought, but you definitely don't want to store any critical user information in a cookie. i'd store some kind of server-generated client token in the cookie. on the server i'd store the client token along with some attributes of the client like IP address, browser being used, last request date/time and a few other things i could find. when a request is submitted, check for the presence of the cookie, read the client token, retrieve the client attributes from the table and compare them to the current request and, if everything checks out, let them in. if it doesn't redirect them to the login page. since i've never done anything like this, i'm sure there are some holes in there somewhere. perhaps someone can provide some more insight. edit: i should have added that i run a web-based secure personal location management system and i would never implement something like this. auto-logging users in, keeping them logged in, storing usernames client side, etc... they're all security compromises waiting to happen.
  9. that's disturbing. oh well, in the long run it will mean more work for geeks like me that make a decent living fixing the mistakes of others.
  10. wow! i didn't know that. sure wish they'd deprecate it and people wouldn't use it.
  11. i'm assuming you know how to paginate your data and simply want to know how to the create the page links. i wrote the function below. simply pass in the current page number, the total number of pages and the url to go to when each page is clicked. the function appends a page variable, pg, to the end of url. it returns the HTML for the page numbers. public function pageLinks($pageNumber, $pageCount, $url) { $pl = "Total Pages: $pageCount<br/>"; $multiples = ceil($pageCount / 10); $theMultiple = ceil($pageNumber / 10); $qSep = strpos($url, '?') ? '&' : '?'; // newer elements available? if ($theMultiple > 2) { $pl .= "<a href='${url}${qSep}pg=1'>< Newest</a> "; } if ($theMultiple > 1) { $pl .= "<a href='${url}${qSep}pg=" . ((($theMultiple-2) * 10) + 1) . "'>< Newer</a> "; } // current multiple $startPage = (($theMultiple - 1) * 10) + 1; $endPage = min($theMultiple * 10, $pageCount); for ($i = $startPage; $i <= $endPage; $i++) { $pl .= " " . (($pageNumber == $i) ? "<b>$i</b>" : "<a href='${url}${qSep}pg=$i'>$i</a>"); } $pl .= " "; // older elements available? if ($theMultiple < $multiples) { $nextMultiple = ($theMultiple * 10) + 1; $pl .= "<a href='${url}${qSep}pg=" . $nextMultiple . "'>Older ></a> "; } if ($theMultiple < $multiples - 1) { $pl .= "<a href='${url}${qSep}pg=$pageCount'>Oldest ></a>"; } return $pl; } // pageLinks
  12. is error reporting turned on? put this line where your script first starts execution... error_reporting(E_ALL);
  13. a blank page, eh? i wonder if the redirect is working then. comment out this line: header('location: index.php'); and replace it with: print "user/pass validated"; what happens?
  14. for someone who's seeking help, you're not providing much to go on. if it's failing, what are the errors?
  15. i wouldn't code it this way personally, but this should get you somewhere... function verify_Username_and_Pass($un, $pwd) { $query = "SELECT count(*) FROM users WHERE username = ? AND password = ?"; $stmt = $this->conn->prepare($query) or die($this->conn->error); $stmt->bind_param('ss', $un, $pwd); $stmt->execute(); $stmt->bind_result($count); $success = $stmt->fetch(); $stmt->close(); return ($success && $count > 0); }
×
×
  • 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.