我有 3 个文件。我会给你一个确切的例子:
一个.php
<form action="b.php" method="POST">
Enter age:
<input type="text" name="age"><br>
<input type="submit" value="Save">
</form>
b.php
<?php
$age=$_POST["age"];
if (is_numeric($age))
{
header("Location: c.php");
exit();
}
else
{
echo "Age invalid!";
}
?>
c.php
<?php
//i want to use the $age variable here
echo $age;
?>
如何使用in 中的$age
变量?b.php
c.php
我也尝试过 session_start(); at fileb.php
并使用$_SESSION["age"]=$_POST["age"];
inb.php
然后$_SESSION["age"]
inc.php
而不是,$age
它仍然没有工作。
我也尝试过包含但也没有让我到任何地方......也许我没有正确使用它。