[EDIT]: problem solved, please see comments (there was a typo in the code).
In the process of learning PHP, I am trying to pass data from an HTML form to a PHP file, through a form and the POST method.
Here is the code for the form:
<html>
<head>
<title>
</title>
</head>
<body>
<form method"post" action="grab.php">
<p>First Name: <input type="text" name="fname"/></p>
<p>Last Name: <input type="text" name="lname"/></p>
<p><input type="submit" name="submit" value="send"/></p>
</form>
</body>
</html>
And here is the code for the action PHP file:
<?php
$first_name = "";
$last_name = "";
$first_name = $_POST['fname'];
$last_name = $_POST['lname'];
echo "The first name is: ".$first_name." and the last name is: ".$last_name;
?>
When I try to submit the form, I get the following error message:
Notice: Undefined index: fname in /Applications/MAMP/htdocs/phpsection/grab.php on line 6
Notice: Undefined index: lname in /Applications/MAMP/htdocs/phpsection/grab.php on line 7
Any idea what is wrong?
Thank you.