how do I implement a visitor counter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pitchke
    New Member
    • Sep 2007
    • 7

    how do I implement a visitor counter

    hey guys....
    i have developed a login page..but i want to have a count of no. of people who have visited and the links they have clicked on.....i want to post this on to the server so that i can send it to the database....
    Kindest regards....
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Firstly, a title like help!!! does not describe your problem at all. So I´ve changed that.

    Secondly, show us the code you have developed so far to accomplish this and we will probably be able to help you out.

    Ronald

    Comment

    • pitchke
      New Member
      • Sep 2007
      • 7

      #3
      hey i'm so sorry i was not aware...shall not do it again...
      the code is below:
      [php]
      <?php
      session_start() ;
      $_SESSION['UserID'] = "";
      $_SESSION['UserName'] = "";

      if(!$_POST)
      {
      header("Locatio n:enter.php");
      exit();
      }


      if( $_POST["txtUserNam e"] == "" )
      {
      print( $_POST["txtUserNam e"] );
      header("Locatio n:enter.php?Err orMessage=User name field is empty");
      exit();
      }

      $dbCon = @mysql_connect( localhost, "root", "xx");
      if(!$dbCon)
      {
      header("Locatio n:enter.php?Err orMessage=Unabl e to connect to database,Try after some time");
      exit();
      }

      if(!@mysql_sele ct_db("web", $dbCon))
      {
      header("Locatio n:enter.php?Err orMessage=Unabl e select the database");
      print "hi";
      mysql_close($db Con);
      exit();
      }


      $query = "SELECT UserId, Loginname FROM web.webusers WHERE LoginName ='".$_POST['txtUserName']."' AND Password = '".$_POST['txtPassword']."' ";

      $resultSet = mysql_query($qu ery);
      $rows = mysql_numrows($ resultSet);
      if( $rows != 1 )
      {
      mysql_close($db Con);
      print "hello";
      header("Locatio n:enter.php?Err orMessage=Login failed, Try again");
      exit();
      }

      $UserId = mysql_result( $resultSet, 0, 'UserId' );
      $UserName = mysql_result( $resultSet, 0, 'Loginname' );

      //$details = "INSERT INTO web.viewhistory (address,count) VALUES (' ',".$count.") ";

      $_SESSION['UserID'] = $UserId;
      $_SESSION['UserName'] = $UserName;
      $result = mysql_query($de tails);

      mysql_close($db Con);

      ?>
      <html>

      <title>PHP| Home</title>
      <body background="nti mage.gif">

      <h1>Welcome to the world of PHP!!!!!!!!</h1>
      <h1 align=""right"> PHP </h1>
      <ul>
      <TABLE width=15% height=150% bgcolor=black border=1 align=top>
      <li vlink="aqua"><a href="intro.htm "><FONT size=3 face="Tahoma" color=black><bl ink><em>Getting started with PHP</em></blink></td></tr></li>
      <li align=""center" ><a href="var.htm"> <FONT size=3 face="Tahoma" color=black><em >Variables</em></td></tr></li>
      <li align=""center" ><a href="func.htm" ><FONT size=3 face="Tahoma" color=black><em >Functions</em></td></tr></li>
      <li align=""center" ><em><a href="db.htm">< FONT color="black" face="Tahoma">< em>Database Interactions</em></FONT></a></td></tr></li>

      </TABLE>
      </td>

      <td>
      <TABLE width=85%>
      <tr><td>
      </td></tr>
      </TABLE>
      </td>

      </tr>

      </TABLE>

      </body>
      </html>
      [/php]
      Last edited by ronverdonk; Sep 19 '07, 12:46 PM. Reason: enclose code within code tags

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        Are you making a tutorial website? -_-

        Anyway, I don't see any sort of visitor counting. That's the code we need to see.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Next time, enclose your code within code tags! Makes it a lot easier to read for our members.

          moderator

          Comment

          Working...