[PHP] Does HTACCESS block $_POST ?

Hello.

Ive got an odd problem with my php (seems a recent issue)...

Heres my htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)$ vyb6a.php [QSA,L]

for the last few days, i'm no longer receiving ANY $_POST values...

ive even got $r=print_r($_POST,true); echo $r; at the beginning of my
script before anything else & nothing comes through. so i do think is
an htaccess issue.

Does anyone have an idea how to solve ? (im using clean URLs)

Ps the script works fine - apart from receiving $_POST values

--

Gordon.

FORM:- (uses w3css - been using w3css for years...

<form class="w3-container" action="/vyb/" method="post">

<select class="w3-select w3-select" name="viewaddress"
onchange="this.form.submit()">
<option value="">Home/main office</option>
<option value="909-2-2" >(909-2-2) 88 Newland St, Bondi Junction NSW
2022</option>
</select>

<br /><br />
<select class="w3-select w3-yellow" name="CHANGEURL">
<option value="/vyb/">no action specified - select an action</option>
<option value="/vyb/desc" >update business/location description</option>
</select>
<select class="w3-select w3-yellow" name="DISPLAY">
<optgroup label="FUNCTIONS NOT GOING YET">
<option value="ACTIONupdatestatus" >Update your business status</option>
<option value="ACTIONMAIL" >Change frequency of emails</option>
<optgroup label="Description">
<option value="ACTIONmodifydescription" >Modify business/location
description</option>
<optgroup label="Services">
<option value="ACTIONviewservice" >View Services</option>
<option value="ACTIONaddservice" >Add a Service</option>
<option value="ACTIONremoveaservice" >Remove a Service</option>
</select>

<p><button class="w3-btn w3-teal">View Location</button></p>
</form>

HTACCESS:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)$ vyb6a.php [QSA,L]

END HTACCESS

top few lines of my php script - vyb6a.php

<?php

$xa=print_r($_POST,true);
$va="BLUE\n$xa\n";
//echo "<pre>$va</pre>\n";

include_once("../../includes/initial.inc.php");
include_once("V03/vybMODV03_job_modify.inc.php");
include_once("V03/vybMODV03_mail_update.inc.php");
include_once("V03/vybMODV03_cookies.inc.php");
include_once("V03/vybMODV03_get_inputs.inc.php");
include_once("V03/vybMODV03_log_helpers.inc.php");
ini_set("precision", "16");

$re=$template_data['viewaddress'];
$va.="VA 1abr '$re' \n$xa\n";

echo "<pre>$va</pre>\n";

NOTE - if I un-comment the 1st echo, NOTHING is displayed on screen..

the script works perfectly fine & all the included files work (based
on login & URL) - im just adding my next stage - submitting data...

Gordon

On Mon, 21 Apr 2025 at 16:05, JEFFRY KILLEN <jekillen@prodigy.net> wrote:

A quick checklist:

1: is the form submitting the values set to POST or GET?
2: do the form fields have NAMES? They have to have names to
   be sent so you get $_POST['form field name']: ['form field value']'
3: CHECK in the script that is supposed to process the $_POST
    index/values is receiving the $_POST
if(isset($_POST)
{
  // test for a specific field
if(isset($_POST['testfield']))
  {
   // proceed with processing
  }
}
else if(isset($_GET)
{
  // test for a specific field
if(isset($_GET['testfield']))
  {
   // proceed with processing
  }
}

I find that with recent versions of PHP that
if($_POST) //or if($_GET)
does not necessarily work

Also are the values being submitted synchronously or asynchronously?

I hope you do not feel insulted by this.
I have subjected myself to this in my debugging mostly to
benefit. Your form may have changed or some other issue
has crept in that is obvious when you see it, but hard to spot.

Work On....
JK

On 4/20/25 23:27, gordonisnz@gmail.com wrote:

Hello.

Ive got an odd problem with my php (seems a recent issue)...

Heres my htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)$ vyb6a.php [QSA,L]

for the last few days, i'm no longer receiving ANY $_POST values...

ive even got $r=print_r($_POST,true); echo $r; at the beginning of my
script before anything else & nothing comes through. so i do think is
an htaccess issue.

Does anyone have an idea how to solve ? (im using clean URLs)

Ps the script works fine - apart from receiving $_POST values

Hi, I think my code has posted variables through rewrites all the time. I've never considered that it wouldn't work.

I went through a troubleshooting process in my mind (a dark and dangerous place) and came up with this.

As a test, you might take out the htaccess and post to the page directly (unclean URLs) and see if the POST variables come through.

Is the posted data present in $_REQUEST?

Does your php.ini or other source of settings have enable_post_data_reading set on? I didn't even know that this setting existed until I went searching this morning.

Is your php_max_size variable set in such a way to interfere with the posted variables?

Perhaps you should try another script with just the first line (the print_r) statement and see if you can post to that, with and without a rewrite.

Does your page contain a class? If so, is your print_r accidentally inside the class? (I got this from a 12 year old stack overflow post)

Let us know how your troubleshooting is going. Hopefully some others will chime in.

Ed Greenberg

Hi again. Thank you Ed. - its 4 am & I'm going back to bed.. however
this is getting WEIRD.. (midnight snack..)

data testing: - phpinfo();

enable_post_data_reading = On
post_max_size = 50M

1) I've created a test.php script:

<?php
$xa=print_r($_POST,true);
$va="BLUE\n$xa\n";
$xa=print_r($_REQUEST,true);
$va.="REd\n$xa\n";
echo "<pre>$va</pre>\n";
exit;
?>

2) Ive modified my html form:- (the top part of the form is a
duplicate of the complete form...) - addresses are just my test
account / fake

// test form
<form action="/vyb/test.php" method="post">
<select class="w3-select" name="viewaddress" onchange="this.form.submit()">
<option value="">Home/main office</option>
<option value="909-2-2" selected="selected">(909-2-2) 88 Newland St,
Bondi Junction NSW 2022</option>
</select>
<p><button class="w3-btn w3-teal">View Location</button></p>
</form>

<br /><br />

// original form
<form action="/vyb/" method="post">
<select class="w3-select" name="viewaddress" onchange="this.form.submit()">
<option value="">Home/main office</option>
<option value="909-2-2" selected="selected">(909-2-2) 88 Newland St,
Bondi Junction NSW 2022</option>
</select>
<select class="w3-select w3-yellow" name="CHANGEURL">
<option value="/vyb/">no action specified - select an action</option>
<option value="/vyb/desc" >update business/location description</option>
</select>
<select class="w3-select w3-yellow" name="DISPLAY">
<optgroup label="FUNCTIONS NOT GOING YET">
<optgroup label="Services">
<option value="ACTIONviewservice" >View Services</option>
<option value="ACTIONaddservice" >Add a Service</option>
<option value="ACTIONremoveaservice" >Remove a Service</option>
<optgroup label="Location status">
<option value="ACTIONlocationstatus" >Update your address status (in
development)</option>
<option value="ACTIONlocationphone" >Update your phone number for this
address</option>
<optgroup label="Hours">
<option value="ACTIONmodifyhours" >Modify opening hours</option>
<optgroup label="Jobs">
<option value="ACTIONviewjobs" >View your employment requests</option>
<option value="ACTIONaddjob" >Add a new position/job</option>
</select>
<p><button class="w3-btn w3-teal">View Location</button></p>
</form>

RESULTS:-

If i change the SELECT on my 1st form, i *DO* get results... (test.php)

If i do any change to the address on 2nd form - NO RESULTS - both
scripts in the same URL/directory...

I'm using PHP SMARTY - so html form is in the templates directory, &
php scripts in the php directories

back to bed - I'll do an hour or so more test in morning - then more after work.

(Ps - this form is behind a password system - I need to manually
create a test account for anyone - it's not open/public...)

PPS - the blue and red ECHOS are also in the live php - the top few
lines.. No PHP processing before then, and it's blank results.

Oh yes - htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^test.php [L]
RewriteRule ^(.*)$ index.php [QSA,L]

(END HTACCESS)
- i'll want the POSt and GEt values to be avaialble if set...

EXTRA: class ??
I just use functions - been programming a few decades, but all
hand-coded... I rarely use off-the shelf codes...
haven't really got into classes & such..

Goodnight - i'll try again in daylight

On Tue, 22 Apr 2025 at 00:20, Ed Greenberg <edg@greenberg.org> wrote:

Hi, I think my code has posted variables through rewrites all the time.
I've never considered that it wouldn't work.

I went through a troubleshooting process in my mind (a dark and
dangerous place) and came up with this.

As a test, you might take out the htaccess and post to the page
directly (unclean URLs) and see if the POST variables come through.

Is the posted data present in $_REQUEST?

Does your php.ini or other source of settings have
enable_post_data_reading set on? I didn't even know that this setting
existed until I went searching this morning.

Is your php_max_size variable set in such a way to interfere with the
posted variables?

Perhaps you should try another script with just the first line (the
print_r) statement and see if you can post to that, with and without a
rewrite.

Does your page contain a class? If so, is your print_r accidentally
inside the class? (I got this from a 12 year old stack overflow post)

Let us know how your troubleshooting is going. Hopefully some others
will chime in.

--

Gordon.

Off to work soon. But a final test results in interesting results..

HTML:-

<form action="/vyb/index.php" method="post">

<select class="w3-select" name="viewaddress" onchange="this.form.submit()">
<option value="">Home/main office</option>
<option value="909-2-2" >(909-2-2) 88 Newland St, Bondi Junction NSW
2022</option>
</select>

etc....

When i submit the form, it should go to /vyb/index.php and activate
the script...
(i renamed the script to index.php)

HOWEVER - I end up at /vyb/ (no index.php)....

my htaccess:-

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)$ index.php

END HTACCESS (ive taken away the NC, L, QSA etc..

Question: can the htaccess be redirecting the browser & thus losing
the post values ?

Can the redirect occur at htaccess leve - or within the php itself ?
there are 2 x HEADER lines in the php itself - but neither of them go
to /vyb/ url..
(where the script is)

--

Gordon.

Date: Monday, April 21, 2025 15:27:30 +1200
From: gordonisnz@gmail.com

Ive got an odd problem with my php (seems a recent issue)...

Heres my htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)$ vyb6a.php [QSA,L]

for the last few days, i'm no longer receiving ANY $_POST values...

if this issue just started happening it might be good to get some
basic information:

  - what version of php are you currently using?

  - did you recently update versions, if so, from what?

  - other changes that you made?

  - if you changed your settings and/or code can you revert
    back to the state before this issue started showing up
    and then make/test changes one-by-one?