...

View Full Version : POST not working on single page



Keleth
03-09-2009, 06:34 AM
So I've been working on a site recently, and I've run into a serious problem.

I have a login page for the admin section, and a separate login page for the regular users. The admin login works just fine, as well as all the content within the admin section, but when I try to submit the regular login with POST, the $_POST comes up blank. When I change the form to GET, the page passes variables through the URL as expected. For the life of me, I can't figure out whats goin on... the two admin pages are almost identical, yet the form works with GET and not POST.

Does anyone have any idea why this may be? I'd be more then glad to link pages, but the site runs off a dispatcher, so I'd actually have to send you a few pages if you wanted to look at the code.

oesxyl
03-09-2009, 06:40 AM
So I've been working on a site recently, and I've run into a serious problem.

I have a login page for the admin section, and a separate login page for the regular users. The admin login works just fine, as well as all the content within the admin section, but when I try to submit the regular login with POST, the $_POST comes up blank. When I change the form to GET, the page passes variables through the URL as expected. For the life of me, I can't figure out whats goin on... the two admin pages are almost identical, yet the form works with GET and not POST.

Does anyone have any idea why this may be? I'd be more then glad to link pages, but the site runs off a dispatcher, so I'd actually have to send you a few pages if you wanted to look at the code.
post the relevant part of your code, please.

best regards

achcore
03-09-2009, 10:47 AM
Please post the html as well as php code.

Keleth
03-09-2009, 04:14 PM
Ok, don't say I didn't warn ya :p

The form:

<form method="post" action="<?php echo SITEROOT; ?>/process/login">
<input type="hidden" name="clientID" value="<?php echo $pathOptions[0]; ?>">
<div class="tr">
<label class="floatLeft">User:</label>
<div class="textBox"><input type="text" name="username"></div>
</div>
<div class="tr">
<label class="floatLeft">Password:</label>
<div class="textBox"><input type="password" name="password"></div>
</div>
<div id="buttonDiv">
<span class="button"><span><input type="submit" name="submit" value="Submit"></span></span>
<span style="width: 20px;">&nbsp;</span>
<span class="button"><span><input type="reset" name="clear" value="Clear"></span></span>
</div>
</form>


The processing page:

<?php
print_r($_POST);
?>


If I change method="post" to method="get", and print_r($_GET), the stuff that passes shows up fine.

If I were to post everything relating to the two pages (the dispatcher, the verification code, etc), It'd be closer to 200 lines of code :p

Leppy
03-09-2009, 04:23 PM
Are you getting anything if you do this?


print_r($_REQUEST);

Keleth
03-09-2009, 04:26 PM
print_r($_REQUEST) when I have method="post" gives me a black array.

oesxyl
03-09-2009, 04:31 PM
Ok, don't say I didn't warn ya :p

The form:

<form method="post" action="<?php echo SITEROOT; ?>/process/login">
<input type="hidden" name="clientID" value="<?php echo $pathOptions[0]; ?>">
<div class="tr">
<label class="floatLeft">User:</label>
<div class="textBox"><input type="text" name="username"></div>
</div>
<div class="tr">
<label class="floatLeft">Password:</label>
<div class="textBox"><input type="password" name="password"></div>
</div>
<div id="buttonDiv">
<span class="button"><span><input type="submit" name="submit" value="Submit"></span></span>
<span style="width: 20px;">&nbsp;</span>
<span class="button"><span><input type="reset" name="clear" value="Clear"></span></span>
</div>
</form>


The processing page:

<?php
print_r($_POST);
?>


If I change method="post" to method="get", and print_r($_GET), the stuff that passes shows up fine.

If I were to post everything relating to the two pages (the dispatcher, the verification code, etc), It'd be closer to 200 lines of code :p
this is a custom cms?
it's a guess but I think the problem is in dispatcher. Check to see if you do some specific processing based on the method of the request.

best regards

Keleth
03-09-2009, 04:56 PM
Yah, its a custom CMS. The problem is, I don't know what kind of processing could interfere... the only function that's different between the two login pages is one I disabled and it still isn't working.

I didn't come here expecting magical answers, so I apologize if it came across as that... I just wondered if someone ever had a common error that sounds familiar to this. I've been trying to figure out what's killing the post for 3 hours and im pullin my hair out :p

Fumigator
03-09-2009, 05:02 PM
Change the name of your submit button to "submitbtn". As weird as it sounds, I've seen submit buttons named "submit" interfere before.

Keleth
03-09-2009, 05:07 PM
Change the name of your submit button to "submitbtn". As weird as it sounds, I've seen submit buttons named "submit" interfere before.

Sensible, tried it, no luck. Thanks though!

Fumigator
03-09-2009, 05:13 PM
Did you try other browsers? Opera? Safari? IE? FF? Same results with all?

Try hard-coding the "action" property. Does your script really not have an extension; it's just named "login"?

Validate the HTML.

That's the stuff I'd try if I were desperately trying to figure out what's up.

oesxyl
03-09-2009, 05:13 PM
Yah, its a custom CMS. The problem is, I don't know what kind of processing could interfere... the only function that's different between the two login pages is one I disabled and it still isn't working.

I didn't come here expecting magical answers, so I apologize if it came across as that... I just wondered if someone ever had a common error that sounds familiar to this. I've been trying to figure out what's killing the post for 3 hours and im pullin my hair out :p
first try Fumigator suggestion, then if don't give expected results and if you can post some code from dispatcher that you think that are relevant.
Another place to look is how you rewrite the url, if you use this( in htaccess probably).

best regards

abduraooft
03-09-2009, 05:27 PM
Change the name of your submit button to "submitbtn". As weird as it sounds, I've seen submit buttons named "submit" interfere before.
I believe, it makes trouble, only when we use obj.submit(). function to submit our page by javascript. But then the form won't get submitted actaully.

I had some issues with my htaccess rewrite rule, which ruined my GET variables

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
(..a custom framework, where i used the $_SERVER['REQUEST_URI'] to serve the right pages to the user.)

I can't guess something similar with POST though.

Keleth
03-09-2009, 08:00 PM
Ok, so I went through some of the stuff people suggested here and it gets interesting...

So I went back and compared the admin login to the regular login, and there are no processing differences. However, when I remove the action (the form points back to the current page), the post passes. Its when I add the action that the post fails. This seems to indicate that its not the dispatcher... but then I can't think of what else could be the issue...

EDIT: Some more testing and I'm still stumped.

Basically what I did was a few test to see why the admin section worked but the regular section didn't. I setup a page that just sent one variable from the regular section to the admin login processor, and it passed. Then I sent a variable from that same page to the regular login processor, and it failed, even prior to any processing from the dispatch (but after the htaccess obviously). This is, quite literally, driving me nuts.

Keleth
03-09-2009, 11:11 PM
Never mind, thought I solved the problem, I didn't.

EDIT:

And I've figured out the problem... and its more confusing then what it was before.

In the method, I had "/BitBallot/process/login". When I changed it to "/BitBallot/process/login/" (added the last /) it works...
My dispatcher drops that last "/", so to the dispatcher... its the same url...

Keleth
03-10-2009, 05:23 AM
Ok, issue resolved at long last.

Basically, it was Apache's DirectorySlash. Since I had a directory with the same path as the path I sent to the dispatch, there was a conflict where it first tried to add the last /, thinking it was a folder, clearing the POST, then forwarded to the dispatch. Turning off DirectorySlash has solved the problem altogether.

Fumigator
03-10-2009, 06:16 AM
Holy cow what an obscure cause. You just blew my mind.

Glad you got it sorted! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum