I'm totally a beginner at PHP and get a probably silly error there. Any inputs are welcome.
I'm trying to retrieve data from an input box using the global POST but it can't find the input object. Could you please advise?
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
?>
<form action="post.php" method="post">
<input type="text" name="name1">
<input type="text" name="age">
<button type="submit">SUBMIT</button>
</form>
<?php
//POST
//Collect data from the HTML form (invisible)
if (isset($_POST)) {
echo $_POST['name1'] . ", your form is submitted";
}
echo"<br>";
print_r($_POST);
?>
</body>
</html>
Error Message: "Warning: Undefined array key "name1" in C:\xampp\htdocs\PHP_Course\Operators\post.php on line 22 , your form is submitted Array ( )"
Many thanks!!