I am new to PHP. I have written a simple code to collect data from a form using PHP. I am using the POST Method to collect the form data but it goes to the else statement. Can someone please help me out. Thanks in advance!!
My Code-
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="post">
<input type="text" id="name" name="name">
<input type="submit" name="submit" id="submit">
</form>
<?php
if(isset($_POST)){
$x = $_POST['name'];
echo $x;
}else {
echo "failed";
}
?>
</body>
</html>