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!

soapserver.php

$server = new nusoap_server;

$server->configureWSDL('server','urn:server');

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

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

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

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

soapclient.php

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

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

$err = $client->getError();

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

soapform.html

<html>
<body>
    <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"/>
    </form>

</body>
</html>

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 [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

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

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

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

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

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  7. 7

    Do Idle Snowflake Connections Use Cloud Services Credits?

  8. 8

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  9. 9

    Binding element 'string' implicitly has an 'any' type

  10. 10

    BigQuery - concatenate ignoring NULL

  11. 11

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  12. 12

    In Skype, how to block "User requests your details"?

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Pandas - check if dataframe has negative value in any column

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Generate random UUIDv4 with Elm

  17. 17

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  18. 18

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  19. 19

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  20. 20

    EXCEL: Find sum of values in one column with criteria from other column

  21. 21

    How to use merge windows unallocated space into Ubuntu using GParted?

HotTag

Archive