Code does not work when the user submit after entering name and age. Page should submit to the same page and the HTML form should also display along with the result below. Please help me guys!!
<html>
<head>
<title>My first PHP page</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <!-- $_SERVER['PHP_SELF'] array -->
Name: <input type="text" name="name"/>
Age: <input type="text" name="age"/>
<input type="submit"/>
</form>
</body>
</html>
<?php
/* because both the HTML form data and the PHP processing code are in the same script, you will need a conditional check to
see if the form has been submitted */
if ( isset($_POST['submit']) ) { //was the form submitted?
print "Raveen";
//echo "Welcome ". $_POST["name"] . "<br>";
//echo "You are $_POST["age"] years old<br>";
//echo "The path to this file is: $_SERVER[PHP_SELF]";
}
?>