22 lines
593 B
PHP
22 lines
593 B
PHP
<?php
|
|
|
|
use services\Search;
|
|
|
|
header("Access-Control-Allow-Origin: http://localhost:3000");
|
|
header("Access-Control-Allow-Methods: GET");
|
|
header("Access-Control-Allow-Headers: Content-Type");
|
|
header("Content-Type: application/json");
|
|
require_once __DIR__ . '/../services/Search.php';
|
|
|
|
// Get the search query parameter
|
|
$username = isset($_GET['username']) ? $_GET['username'] : '';
|
|
$result = Search::searchByUsername($username);
|
|
if ($result->num_rows == 0) {
|
|
echo "Utente " . $username . " non trovato";
|
|
return;
|
|
} else {
|
|
echo json_encode(array_values($result->fetch_assoc()));
|
|
|
|
}
|
|
|
|
?>
|