vendredi 1 juillet 2016

$_POST variable is empty (and I have used name attributes)

This has been posted here many times and I've read through many of the solutions to no avail.

I'm just starting to learn PHP, and I can't even get a simple example from W3 schools to work correctly.

Here is my html code - "index.html" (as simple as possible)

<html>
    <head>
        <title>Search my Database</title>
        <link rel="stylesheet" href ="style.css">
        <!--<meta http-equiv="refresh" content="1">-->
        <meta name = "viewport" content="width=device-width, initial-scale =1.0">
    </head>
    <body>


            <form action="submit.php" method="post">

                <input type="text" name="username">


                <input type="text" name="password">
                <br>
                <input type="submit" name="submit" class="submit">
            </form>




    </body>



</html>

And here is the file "submit.php":

<html>
<body>


Welcome <?php echo $_POST["username"]; ?><br>
Your password is <?php echo $_POST["password"]; ?>

</body>
</html>

When I enter data into the text boxes and submit the form the output of submit.php is as follows:

Welcome 
Your password is

I have tried using $_REQUEST and I have tried editing php.ini (even though all the values were already high enough to allow for a single line of text to be posted)

Any suggestions? I just want to get started on PHP

Aucun commentaire:

Enregistrer un commentaire