Solved

get/post data not transfered on local apache ?

Posted on 2002-07-14
3
159 Views
Last Modified: 2010-03-04
Hi,
I just set up a local test system (Apache 1.3.26 running as a module, PHP4, mySQL) on a W2K machine. All working fine: accessing database, processing php, showing html, etc.

One problem, though: It seems my local server does not process POST/GET informations from a form.

Look at this:

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title></title>
</head>
<body>

<?php
if (isset($test))echo"$test";
?>

<form action="test.php?test=YES" method="post" >
<input type="Submit" name="Submit" value="Submit">
</form>
</body>
</html>

Saving this code as "test.php", then viewing it within my browser, $test is not printed. That is OK, as $test is not defined yet.

By pressing the "Submit" button, I'd expect "$test" to be defined on the reload of "test.php?test=YES", so there sould be printed "YES" then.

But it isn't. The Variable "$test" is still not known.

I tried "GET" as well. Then installed PHP as CGI executable. Didn't work.
BUT, when I loaded this code to my remote (hosted) server space, it did exactly what it should. "YES" was printed on pressing the submit button.

I understand there must be something missing within my local apache (or php?) configuration.

Having not much experience with server config, I just want to create the same config locally as I have remote, to do some developing.

Any hints ? Thanks a lot.
0
Comment
Question by:MiKo93
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
samri earned 200 total points
ID: 7154771
MiKo98,

i'm still very new to PHP.   One thing I can be sure is, running PHP code as cgi is highly not-recommended for security reason.

I can comment much on why you php code does not produce a desirable result, and why it works on the remote server.

The fact that most of the thing you mentioned worked, shows that your apache+php installation should work fine, except for this specific example.

Perhaps you might want to look at how your hosting site, and you local (test) machine differs.  Yours are Win2K - how about the hosting webserver OS.  This might not be applicable, but something that might be interesting to look at.

How about revising the code to be;
(well it might not work -- I have no php coding knowledge :( )

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title></title>
</head>
<body>

<?php
if (isset($test))echo"$test";
?>

<form action="test.php method="post" >
<input name=test value=someval>
<input type="Submit" name="Submit" value="Submit">
</form>
</body>
</html>

cheers.
0
 

Author Comment

by:MiKo93
ID: 7155074
samri,

thank you very much for your comment. You are right, there is a difference between my host's OS (unix) and my local system (w2k). But this didn't cause the behaviour m.a.

Following your proposal, I managed to get the config of the remote machine and compared it to my own. Guess what ? One single entry of the PHP core configuration had to be changed :

register_globals ON

(it was OFF at my local installation). Now POST/GET works as intended.

I decided to accept your comment as an answer, as it led me to the solution. I'll give it a "medium grade", as it was a good hint, but not directly giving solution ("A" grade would be "haha, just change register_globals to ON").
This has nothing to do with the quality of your comment, but I feel right doing it that way. Hope you agree.

Again, thanks very much.
0
 
LVL 15

Expert Comment

by:samri
ID: 7155963
MiKo,

That was great.  Well... the information that gave is sure very helpful (I ought to be giving you an A grade :)

Well, the for any grades A and B, there is not much explanation required, for C and D, there should be some discussion on how to improve the grade.  Not just like some people-  throw a C, and quiet.

cheers.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now