I have a search bar that only registered people can access. until that's fine my code is working, the problem with each search in the search bar credentials are requested, ie my code requires every time you log in. but I just want to ask you to log in when the person has logged out.
My code:
<?php
include("config.php");
if(!isset($_SESSION['user'])){
echo "you are not logged in,please click here to <a href='memberarea.html'>Login</a>";
} else{
$query = $_GET['query'];
$min_length = 3;
if(strlen($query) >= $min_length){
$query = htmlspecialchars($query);
$query = mysqli_real_escape_string($conn,$query);
$row_results = mysqli_query($conn,"SELECT * FROM books WHERE 'Title' LIKE '%".$query."%' OR 'category' LIKE '%".$query."%'") or die(mysqli_error($conn));
if(mysqli_num_rows($row_results) > 0){
while($results = mysqli_fetch_array($row_results)){
echo "<p><h3>".$results['Title']."</h3>".$results['category']."</p>";
}
}
else{
echo "No results";
}
}
else{
echo "Minimum length is ".$min_length;
}
}
?>