Jump to content

Recommended Posts

Posted

Hey,

I've encountered the weirdest thing ever in my history of PHP

So i'm trying to get my forms working and after hours and hours of frustrating debugging i found out that 

$_SERVER['REQUEST_METHOD'] 

Is always GET...

So i started testing, i've created a template: test 

and on the root page i added a page so my website url = http://localhost/social/test (Social being root folder)

And made this code:

<?php
echo $_SERVER['REQUEST_METHOD'];
if($_SERVER['REQUEST_METHOD'] == 'POST'){
	echo $input->post->comment;
}
?>
<form action="" method="post">
	<textarea name="comment">
		Comment
	</textarea>
	<input type="text" name="a">
	<input type="submit"/>
</form>

As a test. It echoes POST and the value submitted, as expected. 

This code however does not work on a different templte (http://localhost/social/pages/post-comment) that does have urlSegments enabled.

and it displays GET... (When submitted ofcourse)

When i change my test template to allow urlSegments it still doesnt work.

This happened in an almost fresh install of PW. What the hell is going on? And how do i fix it?

Its really frustrating and I can't really continue.

EDIT:
Oh. I use WAMP server on Windows 8

Thanks!

Posted

Sorry to hear, but I can't reproduce... It's always post (of course) when the form method submitted is set to post. The request method is only GET when loading the page. urlSegments doesn't have any effect. I'm on XAMPP Mac.

Posted

u.need add slash after URL

like /social/test/  

 no /social/test  !

so it no 301

redirect convertng post to.get

I also wanted to try this, but in my install here it doesn't redirect to a trailing slash!?

Posted

Sooo... I need to add a / to the url?

I tried it and it doesnt work? 

EDIT:
And LanguagePageNames isnt installed

Posted

Is there any chance that you've got template output caching enabled on the template that is giving you problems?? Because that would be the only way i can think of that POST variables would be ignored (or at least for guest users/not logged in), meaning it would just show the cached version with GET after submitting the form, possibly leaving one very puzzled.

Just like Soma i can't reproduce with you test code, everything works as expected for me. Allowing URL segments doesn't influence POST variables getting through.

Posted

Yes you have to make sure it posts to a url with a trailing slash. Or it will redirect to the /test/ and change to GET.

If urls segment is enabled, its without trailing slash like /test/segment. It doesn't get redirected without trailing slash.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...