0

I use PHP 5.6 and PHPstorm 10.

html code following.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
</head>
<body>
    <form action="hello.php" method="post">
        <input type="text" name="blabla">
        <input type="submit">
    </form>
</body>
</html>

PHP code following .

<?php
    echo $_POST["blabla"];
?>

But if I change the method to GET. It will be work. But I can not get the post value.

Then I install WAMP Server.when just use WAMP Server to access,it worked.why?why I can not use PHPStorm to get the post value.

TIMFUNNY
  • 363
  • 4
  • 9
  • 26

2 Answers2

1

You need to check "Request Type" by below way:-

$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'POST') {
    // Method is POST
    echo "post";
    $data = isset($_POST["blabla"]) ? $_POST["blabla"] : 'notset';
    echo $data;   // print data
} elseif ($method == 'GET') {
    // Method is GET
    echo "get";
} else {
    // Method unknown may be put or delete
     echo "unknown";
}

Hope it will help you :)

Ravi Hirani
  • 6,511
  • 1
  • 27
  • 42
  • return this. Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0 Warning: Cannot modify header information - headers already sent in Unknown on line 0 postnotset – TIMFUNNY Feb 24 '16 at 14:15
  • it just a check . But i still can not get the post value – TIMFUNNY Feb 24 '16 at 14:16
1

remove method = "post" of the form

PHP code following .

<?php
    echo $_REQUEST["blabla"];
?>
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
bhrached
  • 127
  • 1
  • 9