0

I have sent the POST Request with header Content-Type = application/x-www-form-urlencoded via postman.

I get the $_POST array in PHP as the following format. I can't able to access the $_POST in a PHP page. How do I resolve this?

<?php 
switch($method)
{
    case 'registration':
        print_r($_POST);exit;
    break;
}
?>

Result is

Array
    (
        [------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition:_form-data;_name] => "fname"

    bala
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="lname"

    ba
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="uname"

    stsbsathish
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="address"

    chennai
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="email"

    stsbsath2@gmail.com
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="password"

    12345
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="city"

    3
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="state"

    7
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="country"

    8
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="phone"

    897973487
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo
    Content-Disposition: form-data; name="term"

    1
    ------WebKitFormBoundarydUQfNkeuyFTIFgMo--

    )
Martin
  • 22,212
  • 11
  • 70
  • 132
  • 1
    How does the body look in postman? – Ferrybig Jan 31 '19 at 17:02
  • form-data @Ferrybig – Balakumar B Jan 31 '19 at 17:07
  • refer this question, [How to get response of content type application/x-www-form-urlencoded by passing parameters in laravel](https://stackoverflow.com/questions/64227695/how-to-get-response-of-content-type-application-x-www-form-urlencoded-by-passing/64229384) – bhucho Nov 02 '20 at 07:49

1 Answers1

0

Note the header Content-Type should be: 'application/x-www-form-urlencoded' rather use enctype="application/x-www-form-urlencoded".

Martin
  • 22,212
  • 11
  • 70
  • 132
Maksim
  • 511
  • 5
  • 15