Why Can't I Get Apache to Post?

This is a discussion on Why Can't I Get Apache to Post? within the Apache Web Server forums, part of the Web Server and Related Forums category; I don't know if this is the right newsgroup to post this in, but I couldn't find one ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-25-2007
kvnsmnsn@hotmail.com
 
Posts: n/a
Default Why Can't I Get Apache to Post?

I don't know if this is the right newsgroup to post this in, but I
couldn't find one that looked better, so here goes.

My company has a bunch of PHP files that are currently working on one
of our machines with webserver Apache. We moved those files over to
my local machine with webserver Apache. When I take my browser to the
URL corresponding to my machine I get a login prompt asking me for my
username and password. The PHP code gets executed to a place that
says:

if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" ) {
// Redirect user depending upon login
if( $User->login( $txtUsername, $txtPassword ) ) {
if ( $User->simple_interface == "1")
header ("Location: simple_interface.php");
else
header( "Location: view_list.php" );
} else {
header
( "Location: .." . $domain
. ($_GET[ "gid" ] ? "?gid=".$_GET[ "gid" ] : "" ));
} // end if
} else if( isset( $lfu ) && isset( $lfp ) ) {
// Redirect user depending upon login
if( $User->login( $lfu, $lfp ) ) {
if ( $User->simple_interface == "1")
header ("Location: simple_interface.php");
else
header( "Location: view_list.php" );
} else {
header
( "Location: .." . $domain
. ($_GET[ "gid" ] ? "?gid=".$_GET[ "gid" ] : "" ));
} // end if
} // end if

What happens on the machine where this code is working is that
<$_SERVER[ "REQUEST_METHOD" ]> evaluates to "POST" so the first branch
of the outer <if> statement gets executed, and the user is logged in.
But on the machine with Apache installed
<$_SERVER[ "REQUEST_METHOD" ]> evaluates to "GET", and one of <lfu> or
<lfp> are undefined, so none of this code gets executed at all.

Does anyone on this newsgroup know why Apache doesn't post at this
point? Can Apache handle server side variables? Is there a chance
that that's what's messing me up? Am I providing enough information
to answer these questions, or do I need to say more?

What's really confusing me is that both webservers are Apache. The
only differences between the "httpd.conf" files for the two machines
is the groups of <VirtualHost ...> ... </VirtualHost> sections down at
the bottom of each.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

  #2 (permalink)  
Old 07-26-2007
C.
 
Posts: n/a
Default Re: Why Can't I Get Apache to Post?

On 25 Jul, 21:13, kvnsm...@hotmail.com wrote:
> I don't know if this is the right newsgroup to post this in, but I
> couldn't find one that looked better, so here goes.
>
> My company has a bunch of PHP files that are currently working on one
> of our machines with webserver Apache. We moved those files over to
> my local machine with webserver Apache. When I take my browser to the
> URL corresponding to my machine I get a login prompt asking me for my
> username and password. The PHP code gets executed to a place that
> says:
>
> if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" ) {
> // Redirect user depending upon login

<snip>
> } // end if
>
> What happens on the machine where this code is working is that
> <$_SERVER[ "REQUEST_METHOD" ]> evaluates to "POST" so the first branch
> of the outer <if> statement gets executed, and the user is logged in.
> But on the machine with Apache installed
> <$_SERVER[ "REQUEST_METHOD" ]> evaluates to "GET", and one of <lfu> or
> <lfp> are undefined, so none of this code gets executed at all.


Using the request method as part of the input parameters is badly
conceived to begin with.

Multiplexing pages using redirection is badly conceived too. I'm not a
fan of front controller architecture but its a better solution than
this. I would only use redirection to handle exceptions (e.g. user not
authenticated).

A cople of things to note:

header(Location:...

under HTTP/1.1 the URL must not be relative, although it works for
most browsers. In PHP this also changes the status oif the response to
302 - but it should be 307, but again it works for most browsers.

When you do a redirect the new location is fetched via a GET, not a
POST.

Depending on how your system is set up, fetching a URL which points to
a default page (e.g. index.php) without a trailing directory delimiter
in the path will cause a redirection response - e.g. posting to
http://example.com/stuff will cause a redict to http://example.com/stuff/

I suspect that the above is enough to start working out what is
happenning - but I think you need to look at your code and application
architecture more than your webserver config.

C.

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:05 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0