Comments (4)
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.
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.
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.
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)
- Update to use mysqli or PDO HOT 1
- print_r($oMySQL->Select('my_table_name'); returns 1 not an array of all results HOT 4
- Select two tables using select query HOT 1
- query 'SET NAMES utf8' error: mysql_num_rows() expects parameter 1 to be resource HOT 4
- What is the License to use it for a paid / free app. HOT 1
- Return true in ExecuteSQL could be a confusing point
- better data-security with given variable-types HOT 2
- wrong use of settype() HOT 2
- Stops working HOT 4
- Add composer
- Incorrect result of ExecuteSQL when WHERE condition
- Request REPLACE function
- Update datatypes wheretypes
- Is it possible to use keys for both $data and $dataType? HOT 2
- warning: mysql_connect(): No such file or directory in /...
- method add_table_prefix not found HOT 1
- Return error HOT 5
- mysql_query(): 6 is not a valid MySQL-Link resource
- Return errors from database queries HOT 2
- Using a column from the results as a key for the array when result is empty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-mysql-class.