Reputation: 13
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create or Search</title>
</head>
<body>
<form action = "Welcome Screen.php" method = "post">
<div align = "center">
<input type = "submit" name = "Enter Data" value = "Enter Data"/><br />
<input type = "submit" name = "Search Data" value = "Search For Data"/><br />
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "here";
if (isset($_POST['Enter Data']))
{
echo "Here1";
header("Location: Enter Data.php");
exit();
}
else if (isset($_POST["Search Data"]))
{
header("Location: Search Data.php");
echo "here2";
exit();
}
}
?>
</form>
</body>
</html>
I can not seem to figure out why it is not at least entering inside the if statements. I am horribly new to PHP/HTML and will welcome any help. I have looked up this problem and can not seem to find a post that seems to help me solve it. Thanks!
Upvotes: 0
Views: 50
Reputation: 36924
Change
if (isset($_POST['Enter Data']))
to
if (isset($_POST['Enter_Data']))
and
else if (isset($_POST["Search Data"]))
to
else if (isset($_POST["Search_Data"]))
The reason for that is that PHP will always replace the spaces with underlines in your $_GET / $_POST field. You can read more about it in the documentation.
Typically, PHP does not alter the names of variables when they are passed into a script. However, it should be noted that the dot (period, full stop, [and space]) is not a valid character in a PHP variable name. [...] it is important to note that PHP will automatically replace any dots in incoming variable names with underscores.
Upvotes: 2