41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
|
<?php
|
||
|
include_once("db_config.php");
|
||
|
$postdata = file_get_contents("php://input");
|
||
|
echo $postdata;
|
||
|
$request = json_decode($postdata);
|
||
|
$apiergebnis = array();
|
||
|
if(isset($postdata) && !empty($postdata))
|
||
|
{
|
||
|
$pwd = mysqli_real_escape_string($mysqli, trim($request->password));
|
||
|
$email = mysqli_real_escape_string($mysqli, trim($request->username));
|
||
|
$sql='';
|
||
|
$sql = "SELECT * FROM user where (login='$email' OR email = '$email') and password='" . password($pwd) . "';";
|
||
|
|
||
|
echo $sql;
|
||
|
|
||
|
if($result = mysqli_query($mysqli,$sql))
|
||
|
{
|
||
|
$rows = array();
|
||
|
while($row = mysqli_fetch_assoc($result))
|
||
|
{
|
||
|
$rows[] = $row;
|
||
|
}
|
||
|
|
||
|
// echo json_encode($rows);
|
||
|
|
||
|
echo json_encode(
|
||
|
array(
|
||
|
"id" => $rows[0].id,
|
||
|
"login" => $rows[0].login,
|
||
|
"name" => $rows[0].name,
|
||
|
"email" => $rows[0].email,
|
||
|
"token" => uniqid()
|
||
|
));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
http_response_code(401);
|
||
|
}
|
||
|
}
|
||
|
|