PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE [Users] ( username VARCHAR(100), password VARCHAR(100), hash VARCHAR(100) ); INSERT INTO [Users](username, password, hash) VALUES ('123456789', 'password', 'hashnum1'); INSERT INTO [Users](username, password, hash) VALUES ('abcdefgh', 'qwerty123', 'hashnum2'); -- QUERY database SELECT * FROM [Users];
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $query = "SELECT @@version as version;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); printf('DB version (PDO): %s ' . PHP_EOL, $row['version']); // Run query using mysqli /*$result = $mysqli->query($query); $version = $result->fetch_object(); printf('DB version (mysqli): %s ' . PHP_EOL, $version->version);*/ // Select using Laravel /*$version = $db::select($query); printf('DB version (Laravel Query Builder): %s ' . PHP_EOL, $version[0]->version);*/ function login($username, $password) { $sql = "SELECT username, password, hash INTO #tmp_user FROM users WHERE username='$username';" . "SELECT username, password, hash, count(*) cnt FROM #tmp_user GROUP BY username, password, hash;"; $usercheck = $this->db->query($sql)->execute()->fetch(); if ($usercheck['cnt'] != 1) { return false; } else { $sql = "SELECT hash FROM #tmp_user WHERE password='$password'"; $userdata = $this->db->query($sql)->next(); if ($userdata) { return true; } else { return false; } } } $sql = "SELECT username, password, hash INTO #tmp_user FROM users WHERE username='$username';" . "SELECT username, password, hash, count(*) cnt FROM #tmp_user GROUP BY username, password, hash;"; $username = "' + (SELECT TOP 1 username FROM Users) + '"; $pword = "' OR '1'='1"; $uname = "abcdefgh"; //$pword = "qwerty123"; // $result = login($uname, $pword); echo "Password: $pword";
Show:  
Copy Clear