473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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>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 bo*@microsoft.com
mail("em***@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("kr******@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>
Jul 17 '05 #1
4 3475
Kevin schrieb:
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'].


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

Matthias
Jul 17 '05 #2
On 30 Jun 2004 14:50:30 -0700, kr******@hotmail.com (Kevin) wrote:
So why is $_POST empty after posting information. Even $_GET was
empty.


Which version of PHP?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3

"Kevin" <kr******@hotmail.com> wrote in message
news:de**************************@posting.google.c om...
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'].

<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
Jul 17 '05 #4
On Wed, 30 Jun 2004 14:50:30 -0700, Kevin wrote:
all of those returned empty

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


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

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: smilemaster | last post by:
I have recently started experiencing form data loss. Here is an example: ====test_form1.php==== <form method="POST" action="test_form2.php"> <input name="textboxvalue" type="text" size="20">...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
12
by: bb nicole | last post by:
I have do a update profile for company where they can update after view their profile, but it cannot function... I need to submit the whole job portal soon, but still got many problem in my coding,...
3
by: bb nicole | last post by:
Below is my job post code, it cannot post into database... WHAT IS THE PROBLEM OF IT?? <?php session_start(); ob_start(); //connect to server and select database
11
Louis8
by: Louis8 | last post by:
I would be very appreciative of anyone who could show me a better way to do what I did. Complete newbee here. I have a comment form sidebar of blog. I wanted to Name & Comment fields required and...
7
by: php_mysql_beginer911 | last post by:
Hi .. hope someone will help i am trying to figure it out why i cannot post string "union select" every time i try to post data which content union and select .. the page doesn't get posted and...
3
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
4
by: maveri4201 | last post by:
I have written a php script (test3.php), which I attached as a text file. Its includes are also attached as text files. I'm trying to run the script here: http://www.wondergy.com/phptestbed/test3.php...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.