Current time: 04-20-2014, 03:12 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Using the login Details via App
01-24-2012, 11:45 PM
Post: #31
RE: Using the login Details via App
Invalid login my code looks like this now:

// Check membername and HWID
$query = "SELECT member, hwid FROM loginlist WHERE member = '$username'";
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
if ($row['hwid']!=$hwid) {
print_r($row);
die();
echo "INVALID LOGIN";
exit;
Find all posts by this user
Quote this message in a reply
01-24-2012, 11:47 PM
Post: #32
RE: Using the login Details via App
In that snippet there change:

PHP Code:
$query "SELECT member, hwid FROM loginlist WHERE member = '$username'"
To:
PHP Code:
$query "SELECT member, hwid FROM loginlist WHERE member = '{$username}'"
Smile

Quote:Golf and alcohol don't mix, that's why I don't drink and drive!
Video Tutorials: Installing MyBB | Upgrading MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-24-2012, 11:51 PM
Post: #33
RE: Using the login Details via App
Invalid login my code looks now like this :

// Check membername and HWID
$query = "SELECT member, hwid FROM loginlist WHERE member = '{$username}'";
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
if ($row['hwid']!=$hwid) {
print_r($row);
die();
echo "INVALID LOGIN";
exit;

I have changed the last echo "INVALID LOGIN"; to echo "INVALID LOGIN2"; now it says INVALID LOGIN2
Find all posts by this user
Quote this message in a reply
01-24-2012, 11:54 PM
Post: #34
RE: Using the login Details via App
Try changing mysql_fetch_array to mysql_fetch_assoc() Smile

Quote:Golf and alcohol don't mix, that's why I don't drink and drive!
Video Tutorials: Installing MyBB | Upgrading MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-24-2012, 11:56 PM
Post: #35
RE: Using the login Details via App
Invalid Login2

code looks like this now :

// Check membername and HWID
$query = "SELECT member, hwid FROM loginlist WHERE member = '{$username}'";
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$row = mysql_fetch_assoc();
if ($row['hwid']!=$hwid) {
echo "INVALID LOGIN1";
exit;
Find all posts by this user
Quote this message in a reply
01-24-2012, 11:57 PM
Post: #36
RE: Using the login Details via App
It needs to be mysql_fetch_assoc($result) Toungue

Quote:Golf and alcohol don't mix, that's why I don't drink and drive!
Video Tutorials: Installing MyBB | Upgrading MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-24-2012, 11:59 PM
Post: #37
RE: Using the login Details via App
Invalid Login2

code looks like this :

// Check membername and HWID
$query = "SELECT member, hwid FROM loginlist WHERE member = '{$username}'";
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
if ($row['hwid']!=$hwid) {
echo "INVALID LOGIN1";
exit;
Find all posts by this user
Quote this message in a reply
01-25-2012, 12:00 AM
Post: #38
RE: Using the login Details via App
Ok, post your full code in php tags again Smile

Quote:Golf and alcohol don't mix, that's why I don't drink and drive!
Video Tutorials: Installing MyBB | Upgrading MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-25-2012, 12:01 AM
Post: #39
RE: Using the login Details via App
(01-25-2012 12:00 AM)Tom K. Wrote:  Ok, post your full code in php tags again Smile
PHP Code:
<?php

error_reporting
(0);

// Database settings
$host      'localhost';        
$user      '';         
$password  '';        
$database  '';        
$conn mysql_connect($host,$user,$password) or die ('Error connecting to MySQL database.');
$conn mysql_select_db($database) or die ('Error selecting database.');

$hwid mysql_real_escape_string($_GET['hwid']);
if (
$hwid == '') {$hwid='?';}
$author mysql_real_escape_string($_GET['author']);
$username mysql_real_escape_string($_GET['username']);
$password mysql_real_escape_string($_GET['password']);
//get the user info
$query "SELECT * FROM mybb_users WHERE LOWER(username) = '{$username}';"
//make it into a mysql_assoc_array
$resultmysql_query($query);
$resultarr mysql_fetch_assoc($result);
$salt $resultarr['salt'];
$hash md5(md5($password.$salt).$salt);

//check your hash against the one in the table
if ($resultarr['hash'] == $hash)
{
    
// Check membername and HWID 
    
$query "SELECT member, hwid FROM loginlist WHERE member = '{$username}'"
    
$result mysql_query($query);
if (
$result && mysql_num_rows($result)) {
$row mysql_fetch_assoc($result);
if (
$row['hwid']!=$hwid) {
echo 
"INVALID LOGIN1";
exit;
        }
    }
    
// Update loginlist
    
$ip $_SERVER['REMOTE_ADDR'];
    
$lastday $firstday time();
    
$cntr 1;
   
$author $author;
    
$query "SELECT member, ip, author, cntr FROM loginlist WHERE member = '$username' AND ip = '$ip'";
    
$result mysql_query($query);
    if (
$result && mysql_num_rows($result)) {
        
$row mysql_fetch_array($result);
        
$row[cntr] += 1;
        
$lastday time();
        
$row[author] = $author;
        
$query "UPDATE loginlist SET lastday = '$lastday', cntr = '$row[cntr], author = '$row[author]' WHERE member = '$username' AND ip = '$ip'";
        
$result=mysql_query($query);
    } else {
        
$query="INSERT INTO loginlist (member, hwid, ip, lastday, firstday, cntr, block) VALUES ('$username', '$hwid', '$ip', '$lastday', '$firstday', '$cntr', '$author', '0')";
        
$result=mysql_query($query);            
    }    
    
// Check if IP address is blocked
    
$query "SELECT * FROM loginlist WHERE ip = '$ip'";
    
$result mysql_query($query);
    if (
$result && mysql_num_rows($result) == 1) {
        
$row mysql_fetch_array($result);
        if (
$row[block] == 1) {
            echo 
"INVALID LOGIN2";    
            exit;
        }
    }
    echo 
"VALID LOGIN";
} else {
    echo 
"INVALID LOGIN3";

?>
Find all posts by this user
Quote this message in a reply
01-25-2012, 12:05 AM (This post was last modified: 01-25-2012 12:05 AM by Tom K..)
Post: #40
RE: Using the login Details via App
Ok this bit:
PHP Code:
 // Check if IP address is blocked
    $query = "SELECT * FROM loginlist WHERE ip = '$ip'";
    $result = mysql_query($query);
    if ($result && mysql_num_rows($result) == 1) {
        $row = mysql_fetch_array($result);
        if ($row[block] == 1) {
            echo "INVALID LOGIN2";    
            exit
;
        

Replace with this:
PHP Code:
 // Check if IP address is blocked
    $query = "SELECT * FROM loginlist WHERE ip = '{$ip}' LIMIT 1;";
    $result = mysql_query($query);
    if ($result) {
        $row = mysql_fetch_assoc($result);
        if ($row['block'] == 1) {
            echo "INVALID LOGIN2";    
            exit
;
        

Quote:Golf and alcohol don't mix, that's why I don't drink and drive!
Video Tutorials: Installing MyBB | Upgrading MyBB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication