Minor - replace tabs to spaces in php integration sample
This commit is contained in:
parent
cae9fc70fe
commit
84741e2882
@ -17,19 +17,19 @@ $pass = get_from_post_or_empty('password');
|
|||||||
|
|
||||||
$was_successful = false;
|
$was_successful = false;
|
||||||
if ($user && $pass) {
|
if ($user && $pass) {
|
||||||
require_once('integration.php');
|
require_once('integration.php');
|
||||||
if (authme_check_password($user, $pass)) {
|
if (authme_check_password($user, $pass)) {
|
||||||
printf('<h1>Hello, %s!</h1>', htmlspecialchars($user));
|
printf('<h1>Hello, %s!</h1>', htmlspecialchars($user));
|
||||||
echo 'Successful login. Nice to have you back!'
|
echo 'Successful login. Nice to have you back!'
|
||||||
. '<br /><a href="form.php">Back to form</a>';
|
. '<br /><a href="form.php">Back to form</a>';
|
||||||
$was_successful = true;
|
$was_successful = true;
|
||||||
} else {
|
} else {
|
||||||
echo '<h1>Error</h1> Invalid username or password.';
|
echo '<h1>Error</h1> Invalid username or password.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$was_successful) {
|
if (!$was_successful) {
|
||||||
echo '<h1>Login sample</h1>
|
echo '<h1>Login sample</h1>
|
||||||
This is a demo form for AuthMe website integration. Enter your AuthMe login details
|
This is a demo form for AuthMe website integration. Enter your AuthMe login details
|
||||||
into the following form to test it.
|
into the following form to test it.
|
||||||
<form method="post">
|
<form method="post">
|
||||||
@ -42,9 +42,9 @@ into the following form to test it.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_from_post_or_empty($index_name) {
|
function get_from_post_or_empty($index_name) {
|
||||||
return trim(
|
return trim(
|
||||||
filter_input(INPUT_POST, $index_name, FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR | FILTER_FLAG_STRIP_LOW)
|
filter_input(INPUT_POST, $index_name, FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR | FILTER_FLAG_STRIP_LOW)
|
||||||
?: '');
|
?: '');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@ -34,13 +34,13 @@ function authme_check_password($username, $password) {
|
|||||||
*/
|
*/
|
||||||
function authme_get_hash($username) {
|
function authme_get_hash($username) {
|
||||||
// Add here your database host, username, password and database name
|
// Add here your database host, username, password and database name
|
||||||
$mysqli = new mysqli('HOST', 'USER', 'PWD', 'DB');
|
$mysqli = new mysqli('HOST', 'USER', 'PWD', 'DB');
|
||||||
$authme_table = 'authme';
|
$authme_table = 'authme';
|
||||||
|
|
||||||
if (mysqli_connect_error()) {
|
if (mysqli_connect_error()) {
|
||||||
printf('Could not connect to AuthMe database. Errno: %d, error: "%s"',
|
printf('Could not connect to AuthMe database. Errno: %d, error: "%s"',
|
||||||
mysqli_connect_errno(), mysqli_connect_error());
|
mysqli_connect_errno(), mysqli_connect_error());
|
||||||
} else {
|
} else {
|
||||||
$stmt = $mysqli->prepare("SELECT password FROM $authme_table WHERE username = ?");
|
$stmt = $mysqli->prepare("SELECT password FROM $authme_table WHERE username = ?");
|
||||||
$stmt->bind_param('s', $username);
|
$stmt->bind_param('s', $username);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@ -48,7 +48,7 @@ function authme_get_hash($username) {
|
|||||||
if ($stmt->fetch()) {
|
if ($stmt->fetch()) {
|
||||||
return $password;
|
return $password;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user