Cannot read information from form using POST or GET ($_Post is empty)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin

    Cannot read information from form using POST or GET ($_Post is empty)

    I am having problems in my php code. I am relatively new to php but I
    know some basics.

    This is the problem:

    when i try to echo some information that is typed into form back to
    the screen i get absolutely nothing. It seems like $_POST['name'] is
    an empty string, along with $_POST and $_GET['name'].

    I looked around to see if someone else had the same problem and found
    that some people's code didn't work because of IE6. but i also tried
    mine on Netscape and i got the same problem.

    So why is $_POST empty after posting information. Even $_GET was
    empty.

    any help is appreciated.


    all of those returned empty

    echo $_POST;
    echo $_POST['name'];
    echo $_GET['name'];



    here is the code:
    the code was originially meant to send an email but i commented the if
    statement out to see why it wasn't working

    <html>
    <head><title>Fe edback</title></head>
    <body>

    <?php

    // Handle POST method.
    //if ($_POST)
    //{

    $name = $_POST['name'];
    $email = $_POST['email'];
    $comments = $_POST['comments'];

    // Compose simple text message:
    $message = "Message from $name
    ($email)\n\nCom ments:\n\n$comm ents";

    // Send message to bob@microsoft.c om
    mail("email@ema il.com", "Feedback", $message);

    // Thank the generous user
    echo "<h1>Cheers !</h1>\n";
    echo $_POST;
    echo $_POST['name'];
    echo $_GET['name'];
    // }
    //else
    //{
    echo($_POST);
    echo($_POST['name']);
    // mail("kreeemer@ hotmail.com", "Feedback", $message);

    echo("yo");
    ?>

    <h1>Feedback</h1>

    <form action="<?=$PHP _SELF ?>" method="Post">

    <p>Name: <input type="text" name="name" /></p>

    <p>Email: <input type="text" name="email" /></p>

    <p>Comments:</p>
    <p><textarea name="comments" ></textarea></p>

    <p><input type="submit" value="Send!" /></p>

    </form>

    <?php

    // }

    ?>

    </body>
    </html>
  • Matthias Esken

    #2
    Re: Cannot read information from form using POST or GET ($_Post is empty)

    Kevin schrieb:
    [color=blue]
    > when i try to echo some information that is typed into form back to
    > the screen i get absolutely nothing. It seems like $_POST['name'] is
    > an empty string, along with $_POST and $_GET['name'].[/color]

    Are you sure that you don't use an outdated PHP version?

    Matthias

    Comment

    • Andy Hassall

      #3
      Re: Cannot read information from form using POST or GET ($_Post is empty)

      On 30 Jun 2004 14:50:30 -0700, kreeemer@hotmai l.com (Kevin) wrote:
      [color=blue]
      >So why is $_POST empty after posting information. Even $_GET was
      >empty.[/color]

      Which version of PHP?

      --
      Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

      Comment

      • Garp

        #4
        Re: Cannot read information from form using POST or GET ($_Post is empty)


        "Kevin" <kreeemer@hotma il.com> wrote in message
        news:de6731f3.0 406301350.12ea7 219@posting.goo gle.com...[color=blue]
        > I am having problems in my php code. I am relatively new to php but I
        > know some basics.
        >
        > This is the problem:
        >
        > when i try to echo some information that is typed into form back to
        > the screen i get absolutely nothing. It seems like $_POST['name'] is
        > an empty string, along with $_POST and $_GET['name'].
        >[/color]
        <snip>

        Superglobals ($_GET, $_POST, etc) are available at all scopes regardless of
        configuration, so this is odd.

        Couple of things that might help you in debugging this and everything else
        ever:
        1) When printing arrays, use print_r() instead of print() - this will expand
        the contents out instead of printing the oh-so-helpful "Array". I always
        prefix it with echo "<pre>"; and postfix with echo "</pre>"; to get the
        formatting right.
        2) Try using $_REQUEST to avoid any confusion about $_GET vs $_POST.
        3) Try turning error output on: error_reporting (E_ALL); in the first line of
        code under debugging.
        4) Try the following:
        echo "<pre>"; print_r($GLOBAL S); echo "</pre>";
        You ought to see SOMETHING in the output you recognise.

        HTH
        Garp


        Comment

        • Jeffrey Silverman

          #5
          Re: Cannot read information from form using POST or GET ($_Post is empty)

          On Wed, 30 Jun 2004 14:50:30 -0700, Kevin wrote:
          [color=blue]
          > all of those returned empty
          >
          > echo $_POST;
          > echo $_POST['name'];
          > echo $_GET['name'];[/color]

          What output *are* you getting? "echo $_POST" or "echo $_GET" should at
          least print the word "Array" to the screen.

          Is your code even being parsed through the PHP parser?

          Try "View Source" in your browser to see.

          --
          Jeffrey Silverman
          jeffrey@pantsjh u.edu
          Drop "pants" to reply by email

          Comment

          Working...