ERROR: localhost redirected you too many times USING PHP

Issue

Good morning, I’m a beginner in PHP. I’m developing an evaluation system for teacher and I have encountered this problem.

This page isn’t working localhost redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS

MY CODE:

<?php 

////DATABASE CONNECTION HERE!
session_start();

include("connection.php");
include("functions.php");
    
    
    //CHECKING THE BUTTON IF IS IT CLICK!
    
        if(isset($_POST['submit'])){
            if(!empty(['submit'])){
                if(!empty(['statement'])){
                    
                    $statement1 = $_POST['statement1'];
                    $statement2 = $_POST['statement2'];
                    $statement3 = $_POST['statement3'];
                    $statement4 = $_POST['statement4'];
                    $statement5 = $_POST['statement5'];
                    $statement6 = $_POST['statement6'];
                    
                    $result=mysqli_query($mysqli, "INSERT INTO results VALUES('','$statement1', '$statement2', '$statement3', '$statement4', '$statement5', '$statement6')");
    
                    if($result){
                        echo'<script type="text/javascript"> alert("YOUR RESPONSE HAS BEEN SUBMITTED. THANK YOU!") </script>';
                        
                    }
                }
                else{ 
                    echo'<script type="text/javascript"> alert("SUBMIT YOUR RESPONSE") </script>';
                    }
            }       
            else{
                echo'<script type="text/javascript"> alert(" PLEASE CLICK ONE RADIO BUTTON PER QUESTIONS! </script>';
                }
        }   
    header("Location: evaluation.php");
    die;
                                    

?>

Solution

  • header() function returns error like ERR_TOO_MANY_REDIRECTS that change page name.php to some url like below.
header("Location: /index.php"); 

Or

header("Location: ./index.php"); 

Or

header("Location: ../application/index.php"); 

Answered By – Uttam Nath

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published