Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once '../functions.php';
- function getUserFromDB($targetUser, $targetPass)
- {
- $user = [
- 'id' => '',
- 'username' => '',
- 'password' => '',
- ];
- $dbConfig = [
- 'hostname' => '127.0.0.1',
- 'user' => 'root',
- 'password' => '1234',
- 'database' => 'internshp',
- ];
- $dbLink = mysqli_connect($dbConfig['hostname'],
- $dbConfig['user'],
- $dbConfig['password'],
- $dbConfig['database']);
- $query = "SELECT *
- FROM user
- WHERE username LIKE '$targetUser'
- AND password LIKE '$targetPass'";
- if($stmt = mysqli_prepare($dbLink, $query))
- {
- mysqli_stmt_execute($stmt);
- mysqli_stmt_bind_result($stmt, $user['id'], $user['username'], $user['password']);
- echo '<pre>';
- while (mysqli_stmt_fetch($stmt))
- {
- //printf("%s\t%s\t%s\n", $user['id'], $user['username'], $user['password']);
- }
- echo '</pre>';
- mysqli_stmt_close($stmt);
- }
- mysqli_close($dbLink);
- return $user;
- }
- $result = getUserFromDB('gigi', 'coco');
- showMe_dump($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement