1.

Solve : Help with login system?

Answer»

First let me introduce myself, I am Danny just got out of high school and now in college trying to start up my own clothing company. I have my website up and it runs fine and just added google checkout carts, but now I want a login system so that I can keep track of my customers and so that they have to be logged in inorder to PURCHASE my shirts. I went to a website where there was a tutorial and examples how to create a login system and so I read it and ext. and uploaded the tables.sql to my Mysql SERVER and all the tables appeared fine then I uploaded all the php files to my directory. Now for example I typed in thisismysite.com/register.php I get this message: Client does not support authentication protocol requested by server; consider upgrading MySQL client What am I doing wrong? this is what the php looks like for connecting to the server: Code: [SELECT]<?

define("DB_SERVER", "10.11.8.195");
define("DB_USER", "notrealusername");
define("DB_PASS", "notrealpassword");
define("DB_NAME", "notrealdbname");


define("TBL_USERS", "users");
define("TBL_ACTIVE_USERS",  "active_users");
define("TBL_ACTIVE_GUESTS", "active_guests");
define("TBL_BANNED_USERS",  "banned_users");


define("ADMIN_NAME", "admin");
define("GUEST_NAME", "Guest");
define("ADMIN_LEVEL", 9);
define("USER_LEVEL",  1);
define("GUEST_LEVEL", 0);

ne("TRACK_VISITORS", true);


define("USER_TIMEOUT", 10);
define("GUEST_TIMEOUT", 5);


define("COOKIE_EXPIRE", 60*60*24*100); 
define("COOKIE_PATH", "/"); 

define("EMAIL_FROM_NAME", "YourName");
define("EMAIL_FROM_ADDR", "[email protected]");
define("EMAIL_WELCOME", false);


define("ALL_LOWERCASE", false);
?>
and this is the database code:
Code: [Select]<?

include("constants.php");
     
class MySQLDB
{
   var $connection;         
   var $num_active_users; 
   var $num_active_guests; 
   var $num_members;       


   FUNCTION MySQLDB(){
     
      $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
      mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
     
     
      $this->num_members = -1;
     
      if(TRACK_VISITORS){
       
         $this->calcNumActiveUsers();
     
         $this->calcNumActiveGuests();
      }
   }

   
   function confirmUserPass($username, $password){
   
      if(!get_magic_quotes_gpc()) {
      $username = addslashes($username);
      }

     
      $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1;
      }

   
      $dbarray = mysql_fetch_array($result);
      $dbarray['password'] = stripslashes($dbarray['password']);
      $password = stripslashes($password);


      if($password == $dbarray['password']){
         return 0;
      else{
         return 2;
      }
   }
   
   
   function confirmUserID($username, $userid){
     
      if(!get_magic_quotes_gpc()) {
      $username = addslashes($username);
      }

     
      $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1;
      }

   
      $dbarray = mysql_fetch_array($result);
      $dbarray['userid'] = stripslashes($dbarray['userid']);
      $userid = stripslashes($userid);

     
      if($userid == $dbarray['userid']){
         return 0;
      }
      else{
         return 2;
      }
   }
   
 
   function usernameTaken($username){
      if(!get_magic_quotes_gpc()){
         $username = addslashes($username);
      }
      $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      return (mysql_numrows($result) > 0);
   }
   
 
   function usernameBanned($username){
      if(!get_magic_quotes_gpc()){
         $username = addslashes($username);
      }
      $q = "SELECT username FROM ".TBL_BANNED_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      return (mysql_numrows($result) > 0);
   }
   
   
   function addNewUser($username, $password, $email){
      $time = time();
     
      if(strcasecmp($username, ADMIN_NAME) == 0){
         $ulevel = ADMIN_LEVEL;
      }else{
         $ulevel = USER_LEVEL;
      }
      $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time)";
      return mysql_query($q, $this->connection);
   }
   
   
   function updateUserField($username, $field, $value){
      $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
      return mysql_query($q, $this->connection);
   }
   
 
   function getUserInfo($username){
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
     
      if(!$result || (mysql_numrows($result) < 1)){
         return NULL;
      }
     
      $dbarray = mysql_fetch_array($result);
      return $dbarray;
   }
   
   
   function getNumMembers(){
      if($this->num_members < 0){
         $q = "SELECT * FROM ".TBL_USERS;
         $result = mysql_query($q, $this->connection);
         $this->num_members = mysql_numrows($result);
      }
      return $this->num_members;
   }
   
   
   function calcNumActiveUsers(){
     
      $q = "SELECT * FROM ".TBL_ACTIVE_USERS;
      $result = mysql_query($q, $this->connection);
      $this->num_active_users = mysql_numrows($result);
   }
   
 
   function calcNumActiveGuests(){
     
      $q = "SELECT * FROM ".TBL_ACTIVE_GUESTS;
      $result = mysql_query($q, $this->connection);
      $this->num_active_guests = mysql_numrows($result);
   }
   
   
   function addActiveUser($username, $time){
      $q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'";
      mysql_query($q, $this->connection);
     
      if(!TRACK_VISITORS) return;
      $q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES ('$username', '$time')";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }
   
 
   function addActiveGuest($ip, $time){
      if(!TRACK_VISITORS) return;
      $q = "REPLACE INTO ".TBL_ACTIVE_GUESTS." VALUES ('$ip', '$time')";
      mysql_query($q, $this->connection);
      $this->calcNumActiveGuests();
   }
   
 
   function removeActiveUser($username){
      if(!TRACK_VISITORS) return;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE username = '$username'";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }
   
   
   function removeActiveGuest($ip){
      if(!TRACK_VISITORS) return;
      $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE ip = '$ip'";
      mysql_query($q, $this->connection);
      $this->calcNumActiveGuests();
   }
   

   function removeInactiveUsers(){
      if(!TRACK_VISITORS) return;
      $timeout = time()-USER_TIMEOUT*60;
      $q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout";
      mysql_query($q, $this->connection);
      $this->calcNumActiveUsers();
   }

 
   function removeInactiveGuests(){
      if(!TRACK_VISITORS) return;
      $timeout = time()-GUEST_TIMEOUT*60;
      $q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE timestamp < $timeout";
      mysql_query($q, $this->connection);
      $this->calcNumActiveGuests();
   }
   
 
   function query($query){
      return mysql_query($query, $this->connection);
   }
};


$database = new MySQLDB;

?>
I Don't know if these are whats causing the problem  but please help.

Thanks in advance,

DannyDoes your host support secure connections?
Have you looked into finding a host that had all that already? I've used lunarpages.com in the past and they offer free software to do logins and shopping carts. If you're really set on your current host and/or just want to figure out how to do it for yourself, you might check out some of the options at sourceforge.net (browse the source code for similar projects and phpbuilder.net
phpbuilder.net has a great forum where you could get all the answers at.



Discussion

No Comment Found