Commit 94b0c438 authored by Paarth's avatar Paarth

Login functionality added

parent 25d2f431
<?php
include_once("database.php");
$postData = file_get_contents("php://input");
$request = json_decode($postData);
if (isset($postData) && !empty($postData)) {
$pwd = mysqli_real_escape_string($mysqli, trim($request->password));
$username = mysqli_real_escape_string($mysqli, trim($request->username));
$sql = "SELECT * FROM users where username='$username'";
if ($result = mysqli_query($mysqli, $sql)) {
while ($row = mysqli_fetch_assoc($result)) {
if (password_verify($pwd, $row['password'])) {
echo json_encode($row);
exit;
}
}
}
http_response_code(404);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment