At the beginning of my website, I ask for a name. I then pass the name over to the homepage that has the same $name
variable. In their homepage, they can press the button "something" to redirect them to the something webpage WITH the variable $name
in the URL. On the homepage, it displays the value of the $name
variable in the echo "<h1>$name's Profile</h1>";
, but for some reason is undefined when I use it on the link. Here is the code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Profile</title>
</head>
<body>
<center>
<?php
$name = $_GET['name'];
echo "<h1>$name's Profile</h1>";
echo "<hr>";
echo "<br>";
echo "<h3>Choose an option</h3>";
if(isset($_GET['btn'])) {
$name = $_GET['name'];
$loc = 'something.php?name=' . $name;
header("Location: " . $loc);
exit();
}
?>
<input type="Submit" value="Something" name="btn">
</center>
</body>
</html>