i have Parse error syntax error unexpected '{' in my code do you have the solution ? I looked for this missing parenthes is but no way to get my hands on it Thanks for your help
<?php
require_once '../src/database.php';
if (isset($_POST)) {
if (!empty(htmlspecialchars($_POST['username']) AND !empty(htmlspecialchars($_POST['password']))) {
$req = $db->prepare('SELECT * FROM users WHERE username = ? AND password = ?');
$req->execute([
'username' => $_POST['username'],
'password' => $_POST['password']
]);
$user = $req->fetchObject();
if ($user) {
$_SESSION['admin'] = $_POST['username'];
header('location.index.php');
}else{
$error = 'identifiants incorrect';
}
}
else{
$error = 'Veuillez remplir tous les champs';
}
}
if(isset($error)) {
echo '<div class="error">'. $error .'</div>';
}
?>