I am trying to make one page with variables on it to go to several other pages. The error I am getting is too many redirects. Here is the code:
input.php - the users inputs variable on this page
<form method="post" action="/var.php" />
<input type="text" name="name" placeholder="name" />
<input type="submit" value="enter" />
</form>
var.php - where all of the variables will be and the redirect
<?php
include_once '/redirect.php';
$name = $_POST['name'];
?>
//and here is /redirect.php
<?php
header('Location: /index.php');
?>
index.php - The main page
<?php
include '/var.php';
echo $name;
echo '<br />';
echo "<a href='/index2.php'>next</a>";
?>
// Index2.php
<?php
include '/redirect.php';
echo $name;
?>
Thanks in advance
Well, I believe you got into an infinite redirect loop. First of all, when you submit a form in input.php
, it will take you to var.php
. Then in var.php
, you redirect to index.php
. In index.php
you include var.php
which has a code to redirect to index.php
again. Therefore, you keep redirect index.php
to index.php
infinitely.
I am trying to make one page with variables on it to go to several other pages
There are many ways to do this. You can use SESSION or use GET to pass the variable across the pages.
In var.php, header() is sending you to a page which in turn send you to the page where header() is. You should try setting the location differently.