mercredi 31 mai 2017

isset($_POST) not working but isset($_GET) working... why?

When i write - if(isset($_POST['submit'])) ,it always evaluates to false.. whereas if i simply change $_POST to $_GET, it works properly.

My HTML code-

<html>
    <body>
        <form action="welcome.php" action="post">
            <input type="text" name="username"> <br>
            <input type="submit" name="send">Click me </input>
        </form>
    </body>
</html>

My PHP code-

<?php
$name="default";
if(isset($_POST['send'])){
    $name = $_POST['username'];
}
echo $name;
?>

The output i get is "default" and not what i type in input field in the html form.. Can you tell why? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire