-2

Before anyone tells me to look at other similar posts, I already have and I cannot find any solution to my problem. I am building a questionnaire for a project, and I am using php 5.6, xampp, phpmyadmin, Phpstorm 2017.1.2 and of course the usual languages html css javacript. In order to write less code, I used the masterpage method to build my website for the questionnaire. I therefore have a do-test.php where I put my questionnaire alone and an index.php where I have the main skeleton of the page. I have my questionnaire form with various fieldsets and their inputs. Lastly I have a input type=submit button that I click and the form is supposed to be submitted. However my $_POST method is not working at all.

The following code does all the work. Unfortunately for reasons yet unknown to me, when the if statement runs, it doesn't even look at the isset or !empty method.

Using an IDE debugger

Debugging the do-test.php without the master-page.: My xdebug (installed in phpstorm), jumps directly from the breakpoint in if statement to the bottom of the page. I tried using an else with a message that "submit is not set" and it shows it before and after submitting the form.

if(isset($_POST['Submit']) && !empty($_POST['Submit'])) {
$results = new Results();
$results->ProcessRequest();
if ($results->isSuccessful()) {
    echo "<script type='text/javascript'>
            alert('Your data is sent to the server');
            </script>";
} else {
    echo "<script type='text/javascript'>
            alert('Something went wrong.');
            </script>";
    }
 }

My http raw post data is visible but the post array is empty. My http raw post data is visible but the post array is empty.

Debuggin the do-test.php with the master-page: Gets me 502 bad gateway error

Debug using localhost

Using this code snippet here I tried to see what is going on. Submitting the form from the master-page or the simple do-test page, gives me the following result: enter image description here

which means that my post array has all the right variables. All that remains is for the method to be executed and for the data to pass into the db.

My post_max_size and variables_order (advise taken from here) are correct. magic_quotes_gpc (from this post) are off in php.ini.

Could it be the http modules that interfere with POST as told by GeorgeMillo here??? If so how do I tamper with those? Could there be something wrong with my version of phpstorm or the php version?

Any suggestion is welcome. Thank you in advance.

Community
  • 1
  • 1
SoftDev30_15
  • 463
  • 7
  • 20
  • instead of `if(isset($_POST['Submit']) && !empty($_POST['Submit'])) {` use `if(count($_POST)>0){` – Alive to die - Anant Apr 21 '17 at 22:27
  • "when the if statement runs, it doesn't even look at the isset or !empty method" so why is that the only code in your question, if it isn't the problem? – miken32 Apr 21 '17 at 22:38
  • See http://stackoverflow.com/q/845021/1255289 – miken32 Apr 21 '17 at 22:39
  • @mike32 error reporting didnt help me. I had already enabled warnings and notices but I was unsuccesful. But thank you for the link, I will keep everything in mind. – SoftDev30_15 Apr 21 '17 at 23:49

1 Answers1

0

I may have written one thing wrong so I gave the wrong impression. I wrote "when the if statement runs", when in fact, the debugger runs and tries to execute the if statement but it doesnt. Sorry for my bad explanation.

The member "Alive or Die" gave me the simple solution of using

if(count($_POST)>0)

and it works!! So I will stick with that. Thanks to everyone for your fast comments and for pointing out the obvious when one cannot see it!!

SoftDev30_15
  • 463
  • 7
  • 20