I am beginner in PHP and I`m getting some error in index.php
"This page isn’t working localhost redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS"
I have searched all over internet and trying all things, but didn't get any result. Please give me some solution for this problem.
<?php
session_start();
include('admin/connect.php');
include('includes/header.php');
$_SESSION['username'];
$profile = $_SESSION['username'];
if($profile==true){
} else{
header('location: index.php');
}
$query = "SELECT * FROM post";
$return = mysqli_query($conn, $query);
if(!$return){
die('Data Could not be fetched'.mysqli_error());
}
while($row = mysqli_fetch_array($return)){
$id = $row['id'];
$p_title = $row['p_title'];
$author = $row['author'];
$category = $row['category'];
$content = $row['content'];
$date = $row['date'];
?>
<div class="blog-div">
<div id="latest-div">
<h1 id="post-title"><?php echo
$p_title; ?></h1>
<p id="post-info">By: <span><?php echo
$author; ?></span> | In: <span><?php echo $category; ?></span> | Last
updated: <?php echo $date; ?></p>
<p><?php echo $content; ?></p>
<a id="read-more-btn" href="blog.php?
id=<?php echo $id; ?>">Read More</a>
</div>
<?php } ?>
</div>
<div id="sidebar-div">
<h3>Latest Post</h3>
<?php
$query = "SELECT * FROM post";
$return = mysqli_query($conn, $query);
if(strlen(!$return)){
die('Data Could not be fetched'.mysqli_error());
}
while($row = mysqli_fetch_array($return)){
$p_title = $row['p_title'];
$author = $row['author'];
$category = $row['category'];
$content = $row['content'];
$date = $row['date'];
?>
<p><?php echo $p_title; ?></p>
<?php } ?>
</div>
<?php
include('includes/footer.php');
?>