Created
May 19, 2015 12:06
-
-
Save ineentho/52cb16fe49c2c4454494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'sten123'); | |
function create_user($username, $password) { | |
global $dbh; | |
$loginStmt = $dbh->prepare('INSERT INTO users (username, password) VALUES(:username, :password)'); | |
$loginStmt->bindValue(':username', $username); | |
$loginStmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT)); | |
return $loginStmt->execute(); | |
} | |
$success = create_user('Ineentho', 'sten123'); | |
if ($success) { | |
echo 'User created'; | |
} else { | |
echo 'User could not be created'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment