Web Analytics Made Easy -
StatCounter Login Counter - CodingForum

Announcement

Collapse
No announcement yet.

Login Counter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Login Counter

    Hi i have a table with usernames & passwords, id, Join Date and another field named 'noli' (number of log ins).

    So when a user signs up the noli field has a default of 0.
    When ever you login it doesnt do anything at the moment, but if you do not get it right it doesnt display the page.

    So when you get it right I need the 'noli' field for the $_POST['username'] to increase by one. Here is my login code.

    PHP Code:
    <?php
    $con 
    mysql_connect("mysql2.freehostia.com","glysim_public","*****");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }
    mysql_select_db("glysim_public"$con);
    $result mysql_query("SELECT * FROM Users WHERE username='$_POST[username]' AND password='$_POST[password]'");
    $check mysql_num_rows($result);
    if(
    $check == 1
    {
    //I would like the code to go here.

    else 
    {
      echo 
    "Invalid Username Or Password, Please <a href='index.html'>Try Again</a>."; return false;
    }  
    mysql_close($con);
    ?>
    I have tried googling for something like this but cannot find anything.
    Thanks,
    Glyn.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #2
    PHP Code:
    $result mysql_query("SELECT id FROM Users WHERE username='$_POST[username]' AND password='$_POST[password]'"); 
    if(
    mysql_num_rows($result) == 1) { 
       
    mysql_query('UPDATE Users SET noli=noli+1 WHERE id='mysql_result($result,0));

    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X