0

I writing php from handling using this page as an example http://www.w3schools.com/php/php_forms.asp

To check if my form data is being passed to my php script, I am using echo statements. I have had no results, despite trying to print both my password and name. I have spent hours inspecting my code, and trying code from different examples, but nothing works.

I have read the stack overflow post form variables not passing to php, but I have confirmed that my php is working correctly, as I am able to print arrays from my database, as well as html paragraphs. Now I am prone to making really stupid mistakes, so it could be something like that, but I have been as thorough as possible.

Here is what I have done. (I have removed everything that is not relavent)

<form action="login.php" method="post">
        <div id="name">
            editors name: <input type="text" name="name">
        </div>
        <div id="pswd">
            password: <input type="password" name="pwd">
        </div>
        <div id="submit">
            <input type="submit">        
        </div>
</form>

login.php

<html>
<body>

    <?php
    echo $_POST["pwd"];
    ?>

</html>
</body>

Thank you very much to anyone who has any ideas. I really hope I did not forget something really stupid.

Community
  • 1
  • 1
Adrian
  • 47
  • 1
  • 6
  • 2
    Have you tried echo var_dump($_POST); to see everything that is posted to the page? – ssaltman Jan 25 '14 at 00:41
  • 4
    Just to be clear w3schools _is not_ W3C – jmoerdyk Jan 25 '14 at 00:45
  • Oh cool I did not even know about that. Here is what it printed (i enterd `buts` in the password field and you can see it here: trainsarray(3) { ["name"]=> string(0) "" ["pwd/"]=> string(4) "buts" ["submit"]=> string(6) "Submit" } The strange thing is it mentiones trains, and trains is the correct password that is stored in my database, but I comented out all my database code. – Adrian Jan 25 '14 at 00:45
  • Thanks jmoredyk I removed the tag. – Adrian Jan 25 '14 at 00:47
  • 1
    Just a note. W3C isn't w3schools - check out http://www.w3fools.com . Your code looks fine and should work. – adamS Jan 25 '14 at 00:48
  • sorry guys, i have something similar to dislexia that causes me to do things like that – Adrian Jan 25 '14 at 00:49
  • anyways, I will study the vardump and play around with things and see if I can figure it out. – Adrian Jan 25 '14 at 00:52
  • 2
    => `["pwd/"]` => note the `/` in there => did you give use your _actual_ code, or what you _thought_ it was, minus the typo in the `name` attribute? – Wrikken Jan 25 '14 at 01:02
  • I copy pasted the relevant code. Yeah that slash is really strange. But the thing is I also have some PDO database code going on that seems to have been included in my vardump... this is very strange and is making my head hurt so I am going to go get some fresh air and come back to this. – Adrian Jan 25 '14 at 01:22

1 Answers1

0

So it works now, I have no idea why it would not work before. Anyways that vardump was pretty usefull for at least letting me know what was going on in the background.

Adrian
  • 47
  • 1
  • 6