Solved

get/post data not transfered on local apache ?

Posted on 2002-07-14
3
160 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

17 Experts available now in Live!

Get 1:1 Help Now