Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code:

HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <?php
if ((!isset($_POST['name'])) || (!isset($_POST['password']))) {
    ?>
    <h1>Prihlaste sa prosim</h1>
    <form method="$_POST" action="secret.php">
        <p><label for="name">Uzivatelske meno</label>
        <input type="text" name="name" id="name" size="15"></p>
        <p><label for="password">Heslo</label>
        <input type="password" name="password" id="password" size="15"></p>    
        <button type="submit" name="submit">Prihlasit</button>
    </form>
    <?php
} else if(($_POST['name'] == 'uzivatel') && ($_POST['password'] == 'heslo')) {
// kombinacia mena a hesla je spravna
echo '<h1>A je to!</h1>';
} else {
    echo 'Neste opravneni pouzivat tuto stranku';
}
?>

</body>
</html>


In browser it shows like this:
http://localhost/secret.php?name=X&password=Y&submit=

And refreshes but nothing happens.

What I have tried:

Google submit/form methods for similiar problem.
Posted
Updated 15-Nov-21 3:01am
v3

1 solution

The method attribute takes one of either "get" (which puts the form inputs into the URL) or "post" (which serialises them into the request, not in the URL). You probably meant to use:

HTML
<form method="post" action="secret.php">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900