Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Kevin
Guest
 
Posts: n/a
#1: Jul 17 '05
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>Feedback</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\nComments:\n\n$comments";

// Send message to bob@microsoft.com
mail("email@email.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
Guest
 
Posts: n/a
#2: Jul 17 '05

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
Andy Hassall
Guest
 
Posts: n/a
#3: Jul 17 '05

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


On 30 Jun 2004 14:50:30 -0700, kreeemer@hotmail.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
Garp
Guest
 
Posts: n/a
#4: Jul 17 '05

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



"Kevin" <kreeemer@hotmail.com> wrote in message
news:de6731f3.0406301350.12ea7219@posting.google.c om...[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($GLOBALS); echo "</pre>";
You ought to see SOMETHING in the output you recognise.

HTH
Garp


Jeffrey Silverman
Guest
 
Posts: n/a
#5: Jul 17 '05

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@pantsjhu.edu
Drop "pants" to reply by email

Closed Thread