Coder Social home page Coder Social logo

Comments (4)

a1phanumeric avatar a1phanumeric commented on July 17, 2024

Hello,

Can you elaborate a little more? Let's say you have a users table, you can get all results from that table using $oMySQL->Select('users'). If you want to get a user with a specific username and password, use:

$where = array();
$where['username'] = 'a1phanumeric';
$where['password'] = 'password'; // Can be MD5 / AES etc...
$oMySQL->Select('users', $where);

from php-mysql-class.

AlbertSanIza avatar AlbertSanIza commented on July 17, 2024

This is the code i am using...

    include_once('class.MySQL.php');
    $oMySQL = new MySQL('TEST', 'root', 'root', 'localhost:3306');
    $myUsername=$_POST['myusername']; //This is sent by the LogIn Form
    $myPassword=$_POST['mypassword']; //This is sent by the LogIn Form
    $Login = array('id' => "$myUsername",'password'=>"$myPassword");
    $Result = $oMySQL->Select('Untitled',$Login);

The problem is that I can't find a way to manipulate $Result, for example I want to compare:

$myUsername to $Result key 'id'
$myPasword to $Result key 'password'

To check if the LogIn credentials are correct

-Sorry bad english, and thanks for your time (: -

never mind my friend, I solved the problem with this code:

    if($Result[id] == $myUsername){
        if($Result[password] == $myPassword){
            //Successful LogIn
            header("Location: http://google.com");
        }
    }
    else{
        //Failed LogIn
        header("Location: http://applesfera.com");
    }

from php-mysql-class.

a1phanumeric avatar a1phanumeric commented on July 17, 2024

Haha! I was just about to say that Select() returns an array that you can use!

Thanks for your interest in my MySQL class - it is an active project so feel free to suggest improvements!

I'll close the issue now :)

from php-mysql-class.

AlbertSanIza avatar AlbertSanIza commented on July 17, 2024

What do you think about this?

function MySQL($Type,$database, $username, $password, $hostname){
     $this->MySQLServer($Type,$database, $username, $password, $hostname);
     $this->Connect();
}

/* *******************
* Private Functions *
* *******************/

private function MySQLServer($Type,$database, $username, $password, $hostname='localhost'){
     if($Type == 0){
        $this->database = $database;
        $this->username = $username;
        $this->password = $password;
        $this->hostname = $hostname;
     }
     if($Type == 1){
        $databaseArray = array(1=>'CUSTOM_database1',2=>'CUSTOM_databas2',3=>'CUSTOM_database3');
        $usernameArray = array(1=>'CUSTOM_username1',2=>'CUSTOM_username2');
        $passwordArray = array(1=>'CUSTOM_password1',2=>'CUSTOM_password2');
        $hostnameArray = array(1=>'CUSTOM_hostname1');

        $this->database = $databaseArray[$database];
        $this->username = $usernameArray[$username];
        $this->password = $passwordArray[$password];
        $this->hostname = $hostnameArray[$hostname];
     }
}

This way the user will only place its connection data once.
//Normal Mode

$oMySQL = new MySQL(0,'my_database','username','password');

//Presets Mode

$oMySQL = new MySQL(1,3,1,2,1);

and the equivalent of this with Normal Mode would be

$oMySQL = new MySQL(1,'CUSTOM_database3','CUSTOM_username1','CUSTOM_password2','CUSTOM_hostname1');

from php-mysql-class.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.