473,396 Members | 2,158 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,396 software developers and data experts.

Form Variables gone missing

Hi Guys,

hope I'm on-topic here - couldn't find any leads with a search so
maybe someone has an idea.

I've got a PHP form that is supposed to set some variables from
its fields and then call itself by the POST method.

Here is e.g. a minimal test version called "top.php":-

#!/usr/bin/php
Content-type: text/html

<HTML>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old! <br>
Welcome <?php echo $name; ?>.<br />
You are <?php echo $age; ?> years old! <br>

<form action="top.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

<? phpinfo(); ?>

</HTML>

When I enter data in the fields name or age, it just gets ignored,
goes missing, thrown away by PHP. The first 4 lines that should
output this info show that the variables are all blank.

The phpinfo() call at the end shows me clearly that register_globals
is on.

The only way I've found so far is with the GET method - there the
expected arrays and variables are also broken,
but $_SERVER["REQUEST_URI"] is correctly set (yipee!) and so
I can parse that myself - sort of defeats the point of PHP though.

What could be the problem here?
Is there some other setting I'm missing?
This stuff all worked without a hitch in PHP3 - has something
else been broken in the name of security?

TIA,
David

Dec 13 '05 #1
9 1612
BTW sorry about the anon post.
Also I meant to say I have
PHP 4.4.0 (cli) (built: Nov 17 2005 20:26:48)
running on SuSe 10 kernel 2.6.13-15-default
David

Dec 13 '05 #2
Why do you have #!/usr/bin/php at the top of your script? Are you
running this from the command line or through a webserver?

Dec 13 '05 #3
ZeldorBlat wrote:
Why do you have #!/usr/bin/php at the top of your script? Are you
running this from the command line or through a webserver?


Both really, the command line only to test for syntax errors etc.,
but both return an error if this line is not present.

I'm using Apache 2.0.54 and it returns an Internal Error (500)
if this is not present. Do you think there is a problem with
my server configuration?

David

Dec 13 '05 #4
You need to integrate php into apache by using mod php. You can test
for syntax errors by logging them and/or printing the error to the
screen, or using the -l option with the php binary.

Dec 13 '05 #5
Sean wrote:
You need to integrate php into apache by using mod php. You can test
for syntax errors by logging them and/or printing the error to the
screen, or using the -l option with the php binary.


Hi Sean,
thanks - I think my problem must be in that area.
I thought I had already done that though.
Under yast - Network Services - http Server the PHP4 module is
installed and enabled. Isn't that enough? Do I have to also manually
make some entries in the config file?
Also, if mod php is not installed, why is httpd executing my files at
all? Shouldn't it in that case just be serving text and html files and
not executing anything?
Most puzzling.

Dec 14 '05 #6
David Johnstone wrote:
Sean wrote:
You need to integrate php into apache by using mod php. You can test
for syntax errors by logging them and/or printing the error to the
screen, or using the -l option with the php binary.
Hi Sean,
thanks - I think my problem must be in that area.
I thought I had already done that though.
Under yast - Network Services - http Server the PHP4 module is
installed and enabled. Isn't that enough? Do I have to also manually
make some entries in the config file?


You have to edit some things in the httpd config file. Goto here if you
are using linux
http://php.mirrors.esat.net/manual/e...ix.apache2.php, or here
http://php.mirrors.esat.net/manual/en/install.unix.php and choose your
install guide.
Also, if mod php is not installed, why is httpd executing my files at
all? Shouldn't it in that case just be serving text and html files and
not executing anything?
Its executing because you have this: #!/usr/bin/php.

You will not be able access from variables; you will not have access to
sessions, etc... When you have mod php working then remove that line
#!/usr/bin/php.
Most puzzling.


Dec 14 '05 #7
Also if you think mod_php is installed and set up correctly, e.g.

LoadModule php4_module modules/libphp4.so & this AddType
application/x-httpd-php .php is in your httpd conf file, then just
remove #!/usr/bin/php and try it.

Dec 14 '05 #8
Thanks Sean, that all sounds logical.
I guess my mistake was trusting yast to do what it said it had
done rather than editing the config files myself. Wouldn't be the
first time a gui setup has put a spanner in the works.
I've now installed xampp, which has a preconfigured apache,
php, mysql etc, and newer versions - and there it all works
fine. As you say, the difference seems to be the LoadModule
entry in httpd.conf - with this knowledge I may try and test
the old installation again.
Thanks again, David

Sean wrote:
Also if you think mod_php is installed and set up correctly, e.g.

LoadModule php4_module modules/libphp4.so & this AddType
application/x-httpd-php .php is in your httpd conf file, then just
remove #!/usr/bin/php and try it.


Dec 14 '05 #9
If it aint broke don't fix it.

Dec 14 '05 #10

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

Similar topics

5
by: lawrence | last post by:
I've this function, which is the method of a class. I'm posting the constructor of the class down below. For some reason, when I fill out a form and hit submit, I'm not getting any values. Can...
2
by: iwasinnihon | last post by:
I don't usually like to do this, but I need help. I have gone over this code and cannot figure out why it doesn't work. First of all it doesn't check to see if you have filled in the required...
1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
1
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
17
by: Jim Little | last post by:
Hello, I'm driving myself crazy either because I'm missing something about ASP.NET, or what I'm trying to do simply can't be done. First, I am not using session variables to track state. My...
1
by: Lisa Calla | last post by:
In my old aspnet app, I had global.vb file in which I kept common code and session variables (connections, connection strings, user info, etc). Since I 'upgraded' to vwd, i get complaints from vwd...
1
by: gzannd | last post by:
I have a problem with submitting a form to a PHP page through a dynamically created IFRAME in IE7. This code works fine in Firefox. However, IE7 submits an empty form--the correct PHP page is...
3
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I have a form, Form1, that shows an instance of Form2 when a user clicks a button. On Form2, the user is to select items, Customer Names for example, from a datagrid control. When the user clicks a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.