Reputation: 13
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;
?>
Upvotes: 1
Views: 1099
Reputation: 672
header("Location: /index.php");
Or
header("Location: ./index.php");
Or
header("Location: ../application/index.php");
Upvotes: 0
Reputation: 121799
Your problem is header("Location: evaluation.php");
. You're inadvertently redirecting to yourself, infinitely.
Remove that statement.
TYPICAL ("CORRECT") BEHAVIOR:
It sounds like maybe you want your "first page" to query the database and present a list of teachers. Specifically, PHP will 1) query the database, 2) generate an HTML form, 3) which containins an HTML table, 4) one row per teacher.
The user selects a teacher (e.g. by clicking a radio button for the teacher on that row), and clicks "submit".
The "second page" might be an "evaluation form" for the chosen teacher. The user clicks "submit" on the second form when he's completed the evaluation.
The "third" (and final) PHP page might be an HTML message that says "Thank you for submitting this evaluation".
No "redirects". Just series of HTML forms, generated one at a time.
Upvotes: 1