how to write isset() function?

Viewed 32

it is only displaying not set everytime I click on the submit button. I am unable to submit the form this is a sample code my actual code is also not working nor this. if there is something wrong with my system please help me with is too.

<?php 

if(isset($_POST['submit'])){
    echo "Button clicked";
} else{
    echo "not set";
}
?>
<html>

<head>
    <title>Sample page</title>
</head>

<body>
    <form name="form1" action="<?php echo    $_SERVER['PHP_SELF'];?>">
        <input type="submit" name="submit" value="submit">
    </form>
</body>

</html>
1 Answers

The default value of a form's method attribute is GET. The data is being submitted in the query string where it will be available through the $_GET superglobal.

To move the data to the request body, where it will be available through the $_POST superglobal, you need to specify method="POST" as an attribute on the <form>.

Related