Jump to content

nankoweap

Members
  • Posts

    113
  • Joined

  • Last visited

Everything posted by nankoweap

  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); }
  16. no tutorials, but i just googled and found this: http://www.ispexperts.com.np/?p=664
  17. cool. ya. i don't use the mysql_* functions. i use the mysqli extension exclusively so i couldn't help you there. glad it's working.
  18. is your application one among many applications on the machine and mysql is a shared resource? if so, it may not be your particular application.
  19. i don't believe foreign keys are supported in the myisam engine. you may want to consider using innodb instead.
  20. looks like a scoping issue, but even if you get that to work, you're still only going to get the last returned row in the array. try something like this: $outArray = array(); while ($row = mysql_fetch_array($query, MYSQL_NUM)) { $outArray[] = array('uid' =>$row['uid'], 'email' => $row['email'], 'name' => $row['name']); } return $outArray; so you're essentially returning an array of arrays. you can loop through them like this: foreach ($outArray as $row) { // do something with the row elements (e.g. $row['uid']) } something like the above cures both issues.
  21. once the email leaves your application, it's subject to the whims of the ether. typically, most email is delivered within seconds, but it can take longer depending upon content, routing, polling interval of the destination client, etc. if your emails aren't delivered within 48 hours, it's likely an issue with the receiving SMTP server and/or the account on that server.
  22. not being familiar with cpanel, i don't know. however, if there's not a way to direct received email from within cpanel, then contact your web hosting provider and ask them if something like this is supported and, if so, how to do it.
  23. i didn't read through the code, but there's no need for multiple login pages. assuming you're storing some kind of token in the user's session that tells your application that the user is logged in or not, do something like this in each required page: if (session_id() == '') { session_start(); } if ( ! isset($_SESSION['nameOfUserToken'])) { $_SESSION['toUrl'] = "the url to which the user will be redirected after successful login"; header("Location:your login page url"); exit(); } then in your login page somewhere after a successful login, check to see if the toUrl token exists in the session. if it does, redirect the user to it. if not, display a successful login page or whatever the detail behavior is. if (isset($_SESSION['toUrl'])) { header("Location:" . $_SESSION['toUrl']); unset($_SESSION['toUrl']); exit(); }
  24. if you're on a unix/linux box, it's simple to parse the emails and do whatever you want with them as they arrive. look into .forward files and how to pipe each email to a process. iirc, the .forward would look something like: | php <your email parsing php file> i've used this method before and it works quite well. google .forward files for the proper syntax. there's a lot you can do with them.
  25. java and javascript are two totally different beasts. no need to learn any java for the google maps stuff. when you start writing the javascript, one of the things you'll need to deal with is *where* to put your code. check out this site: http://spotwalla.com view any public trip and then view the source html. you'll find just about everything you need to get through your project. each time a user views a trip, the database is queried for the location data and the html/javascript is generated dynamically.
×
×
  • 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.