PHP - $_POST variable is not set after form submitting

Sergi Mascaró

I know it's a really asked question, and I'm writing this after checking almost every similar question already asked. In every posted question the solution was to add a name attribute to the form, but I already did it before getting the error.

So this is the problem: I'm trying to implement a basic SOAP web service that by now just prints a sentence using the name passed from the submit form. Here I add both client, server and form codes. I hope someone can help!


$server = new nusoap_server;


$server->wsdl->schemaTargetNamespace = 'urn:server';

                array('username' => 'xsd:string'),  //input parameter
                array('return' => 'xsd:string'),    //output
                'urn:server',                       //namespace
                'urn:server#helloServer',           //SOAP action
                'Registrar un usuari');             //description

function register($username) {
    return 'L\'usuari '.$username.' s\'ha registrat correctament!'; 



$wsdl = "http://localhost/soapserver.php?wsdl";

$client = new nusoap_client($wsdl,'wsdl');

$err = $client->getError();

if ($err) {
    echo '<h2>Constructor error</h2>' . $err;
if ($_POST) {
    echo $_POST;
if (isset($_POST["user"])) {
    echo $_POST["user"];


    <form name="reg_form" action="soapclient.php" method="POST">
                    Username: <input type="text" name="user"/>
                    Password: <input type="password" name="password"/>
                    <input type="submit" name="submit" value="Sign up"/>


What I get when I submit the form is just nothing, as the isset($_POST["user"]) and isset($_POST) return false and therefore nothing happens.

Sergi Mascaró

I'll just post it as an answer so anybody having the same issue can find it easily.

I just solved it myself by changing $_POST by $_REQUEST even I still don't know why the other way wouldn't work...

Edit: after checking deeper into it, I've seen with Chrome that the request sent was a GET request while it should have to be a POST. So finally I've fixed it changing the action from action="soapclient.php" to action="/soapclient.php" and now it sent a POST and the variable $_POST had the value of the username.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at


Login to comment


Symfony 3: set value after submitting a form

Set the focus to input after submitting the form

Variable isn't changing after form submitting

form in php not redirecting to page after submitting

Trying to redirect in PHP after submitting an email form

How to redirect after submitting form in php

stop form from submitting (tried e.preventDefault() after $.post but it stops form from submitting

Django form not submitting on post

AMP form submitting with post

Django form not submitting in POST

Bootstrap form not submitting as POST

Laravel post form is not submitting?

Where form fields data are stored after submitting a FORM in PHP?

After submitting a POST form open a new window showing the result

Registration form refreshes after submitting instead of sending post request in django

Django POST request redirects to empty url after submitting form

Form clears after submitting

Unable to retrieve POST values in php when submitting react/redux form

Submitting large amount of form data to PHP using POST

Form not submitting after form validation

PHP add form refreshes after submitting but doesn't insert into database

php - How to keep form values after submitting to another website?

How to load table data after submitting the form in react js php

Pop-up message after submitting a form with php

How to add message after submitting form? PHP, Wordpress

PHP variables not showing up after submitting form (closed)

I have a blank page after submitting a php mysqli update form,

After submitting a login form, URL remains on the action php

In PHP form, string input gets converted to 0 after submitting