Log in

View Full Version : Resolved POST array empty, but GET array has data



Schmoopy
06-13-2011, 09:41 PM
Hi guys,

Having a strange issue here...

If I submit a form and set the method as post, the post array is completely blank, however if I change the method to get, the array is full of data.

This script used to work, so I don't know what I've done to mess it up, anything obvious you can think of?

I have some htaccess rules that could possibly affect it (not sure)?

Here's the htaccess code anyway:



DirectoryIndex home.php

Options +FollowSymLinks
Options -Indexes

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$

RewriteRule ^(.*)$ http://antidote.dev/$1/ [L,R=301]

RewriteRule ^friends/$ friends.php [L]
#RewriteRule ^shop/(.*)/(.*)/$ shop.php?category=$1&prod=$2 [L]
RewriteRule ^friends/(.*)/$ friends.php?id=$1 [L]
RewriteRule ^friends/(.*)$ friends.php?id=$1 [L]
RewriteRule ^tags/(.*)$ tags.php?tag=$1 [L]
#RewriteRule ^shop/(.*)/$ shop.php?category=$1 [L]

RewriteRule ^shop/category/(.*)/?$ shop.php?category=$1
#RewriteRule ^shop/(.*)/(.*)$ shop.php?category=$1&prod=$2 [L]

RewriteRule ^shop/(.*)/?$ shop.php?prod=$1 [L]

RewriteRule ^links/$ links.php
RewriteRule ^ethics/$ ethics.php
RewriteRule ^tags/$ tags.php
RewriteRule ^friends/$ friends.php
RewriteRule ^blog/$ blog.php
RewriteRule ^downloads/$ downloads.php
RewriteRule ^stockists/$ stockists.php
RewriteRule ^contact/$ contact.php
RewriteRule ^home/$ home.php
RewriteRule ^about_us/$ about_us.php
RewriteRule ^shop$ shop.php
RewriteRule ^basket/$ basket.php [QSA]
RewriteRule ^thanks/$ thanks.php
RewriteRule ^terms/$ terms.php
RewriteRule ^error/$ error.php

ErrorDocument 404 /error

# BEGIN Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>
# END Gzip


The code for the form is just simply:



<form action="/basket" method="post">
<!-- A few form elements -->
</form>


Hope you can help me out.

djr33
06-13-2011, 10:12 PM
I don't have time at the moment to fully debug this, but I had a similar situation a few months ago. It turned out that it was due to the trailing slash on directories. Essentially if the trailing slash was missing, it added it, but in doing so actually did a redirect and dropped the post data (but the get data might still be there). I don't know if this is the problem, but you can test to see if .htaccess is related by using the same script on another page. Pay close attention to the URL (with or without .htaccess) to see if there's anything that might be a problem with that. I hope that helps a bit.

Schmoopy
06-14-2011, 04:55 PM
Hi djr33, yea I forgot to post a reply to this thread, but it's exactly what you said.

Shortly after I made this thread I tried sending requests to /basket/ instead of /basket, and miraculously, it started working :)

Thanks for the help anyway!

traq
06-14-2011, 07:44 PM
have you considered rewriting your htaccess rules to make the trailing slash optional?

Schmoopy
06-14-2011, 08:22 PM
I used to have it like that, but I prefer the URLs with trailing slashes, looks neater imo.