$_POST shows nothing, how to debug ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LaoDe
    New Member
    • Sep 2006
    • 9

    $_POST shows nothing, how to debug ?

    Hi,

    I'm new to PHP and html but think I got to learn that stuff now, after some years Database-experience.

    Iworking at my first form and can't see anything in the PHP-output, even no error-message !??? here are the 'giant' scripts:

    1. html form:
    <html>
    <head>
    <title>My first PHP-Form</title>
    </head>
    <body>
    <form method="post" action="form_ou tput.php" >
    please fill your e-mail adress !
    <input type="text" name="email">
    <input type="submit" value="Go! ">
    </form>
    </body>
    </html>
    ------------------------------------
    2. form_output.php :

    <?php
    error_reporting (E_ALL);
    if (empty($_POST['mail'])) {
    echo "nothing here ";
    } else {
    echo "the mail: ".$_POST['mail'];
    print_r($_POST) ;
    var_dump($_POST );
    }
    echo "strlen($_P OST['mail'])";
    ?>
    -----------------------------------------------------
    when I open the html with firefox I see the form-element and can type in, no errors, everything looks fine !
    When I enter the "go" button, html disapears and the PHP-file is opended by firefox, but totaly empty ! no error, no nothing ! only the URL is to see !???

    it goes more weird, when I insert this line somewhere in the PHP-script:

    echo "<br />\n";

    instead of a blank line, I see while executing: \n";
    and emmidiatly attached the next line of code !

    What's wrong there ? If read dozends of tutorials, all telling the same, as I think, I did !?

    thanks for any tip, LaoDe
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The name of your input field in form1 is 'email'. However, you check and use the $_POST['mail']. Change all these to $_POST['email'].
    [PHP]if (empty($_POST['email'])) {
    echo "the mail: ".$_POST['email'];
    echo strlen($_POST['email']);[/PHP]

    Ronald :cool:

    Comment

    • LaoDe
      New Member
      • Sep 2006
      • 9

      #3
      Hi Roverdonk,

      Thanks for the tip, even so it isn't the problem.

      You are right, during all that testing, I missed that 'e' in the PHP-script, but now, after deleting the that 'e' from the html-script, the problem is still the same, just empty, white screen.

      Could it be, that I need to run this 2 pages through an index.html or index.php via Apache, to make it work ?
      you see, I'm pretty bloody unexperienced in putting the things together. I think I understand some basics of Webserver + html + PHP,+ mySQL but I miss a nice tutorial about how to put all together in the right way.

      any links to that ? thanks a lot for your tip anyway and feel free to ask me anything about databases, you like.

      cheers LaoDe

      Originally posted by ronverdonk
      The name of your input field in form1 is 'email'. However, you check and use the $_POST['mail']. Change all these to $_POST['email'].
      [PHP]if (empty($_POST['email'])) {
      echo "the mail: ".$_POST['email'];
      echo strlen($_POST['email']);[/PHP]

      Ronald :cool:

      Comment

      • LaoDe
        New Member
        • Sep 2006
        • 9

        #4
        Hi,

        Just to let you know: I am 1 step further:

        When I run the form-html as index.html and therfore run it via Apache, the PHP-output is fine.
        So I need to learn now to make Apache + html + PHP + mySQL working fine together.

        Right now I wonder, why Apache comes up with it's dummy page (which is renamed to index.html.org) , when I call 'localhost' and runs my form-html only, if I call localhost/index.html (which contains the form now) expresivly.

        All related scripts are in DocumentRoot "/xampp/htdocs"
        while ServerRoot "/xampp/apache"
        I reduced direcotry index to only:
        DirectoryIndex index.html

        that is default from XAMPP. I didn't change that and proofed it.

        That Indian seems to be a medicine-man !?

        cheers LaoDe

        Comment

        Working...