0
votes

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"

    [email protected]
    ------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--

    )
1
How does the body look in postman?Ferrybig
form-data @FerrybigBalakumar B

1 Answers

0
votes

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