PHP Isset issue

I don’t know why the code below isn’t printing as it should.

<html>
<head>
<title>Form</title>
</head>
<body>

<h1>Enter your name</h1>
<?php

//way to tell if the form has been submitted (If form not submitted, display form again.)
if (!isset($_post['yourCity'])){



	
?>

	<form method="post" action="" />
	<input type="text" name="yourCity" />
<input type="submit">
</form>

<?php
//Process input
}
else
{

// Retrieve information from form submission.

$city = $_POST['yourCity'];
echo "Your city $city";
}
?>
	
</body>
</html>

I believe its as simple as your lowercase $_post in your if?

2 Likes

I think the recommended way to check if the form has been submitted is

if ($_SERVER['REQUEST_METHOD'] != "POST")

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.