Jump to content

nankoweap

Members
  • Posts

    113
  • Joined

  • Last visited

Posts 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. As with privacy, there's a fair bit of convenience to be gained just by loosening the restrictions a little bit.

     

    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.

     

     

     

  4. 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.

  5. i been trying to find out how does a forum do this what code is needed ?

     

    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
    

  6. When I replace the function  verify_Username_and_Pass with the below code and then run the script, all that I get is a blank page.

     

    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?

     

  7. 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);
    }

  8. 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.

  9. yeah i did, so thanks for your help. However, how I can send the email for the clients to receive the email within 48 hours?

     

    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.

  10. 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();
    }
    

  11. 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.

  12. That's exactly the kind of help I was looking for. I guess it's finally time for me to actually learn some java.

     

    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.