0

this is form code:

<div class="login_cont">
<form action="doLogin.php" method="post">
        <ul class="login">
            <li class="l_tit">管理员帐号</li>
            <li class="mb_10"><input type="text"  name="username" placeholder="请输入管理员帐号"class="login_input user_icon"></li>
            <li class="l_tit">密码</li>
            <li class="mb_10"><input type="password"  name="password" class="login_input password_icon"></li>
            <li class="l_tit">验证码</li>
            <li class="mb_10"><input type="text"  name="verify" class="login_input password_icon"></li>
            <img src="getVerify.php" alt="" />
            <li class="autoLogin"><input type="checkbox" id="a1" class="checked" name="autoFlag" value="1"><label for="a1">自动登陆(一周内自动登陆)</label></li>
            <li><input type="submit" value="" class="login_btn"></li>
        </ul>
    </form>
</div>

this is doLogin.php

include_once '../include.php';

$username = $_POST['username'];
$password = md5($_POST['password']);
$verify = $_POST['verify'];
$session_verify = $_SESSION['verify'];
print_r($_POST);
var_dump($_SERVER);

this is var_dump($_SERVER) result enter image description here

why var_dump($_POST) is null?

DarkMoria
  • 90
  • 13
sands.yu
  • 23
  • 7
  • 5
    Please include your code in the post instead of an image – Panda Mar 07 '16 at 06:35
  • 1
    In code you are printing var_dump($_SERVER); while asking for var_dump($_POST); – Deep Kakkar Mar 07 '16 at 06:44
  • try `var_dump($_POST)` you didn't printed $_POST – Sudhakar Annadurai Mar 07 '16 at 06:47
  • var_dump($_POST) is null – sands.yu Mar 07 '16 at 06:48
  • have you passed any values form HTML page? – Sudhakar Annadurai Mar 07 '16 at 06:48
  • make sure to enable error mode using error_reporting(0); in the top of your code – Deep Kakkar Mar 07 '16 at 06:49
  • I copied your code and ran it, and it appears to work just fine. Have you tried a `var_dump` *before* your include? Just wondering if maybe something is happening to it there. (Also, `error_reporting(0)` will turn off all reporting; do `error_reporting(E_ALL)`.) – Davis Mar 07 '16 at 06:50
  • if i method is get, doLogin.php var_dump($GET) is ok.. – sands.yu Mar 07 '16 at 06:51
  • try with `action=""` – devpro Mar 07 '16 at 06:58
  • like this? – sands.yu Mar 07 '16 at 07:16
  • the highlight you are showing in image is information about 'SERVER' configuration for that page. At first running it is showing error for POST/null because there still no value is passed. Pass the values and you will get the values to be fetched from post. It worked for me – Rohan Khude Mar 07 '16 at 08:09
  • 1
    @sands.yu It is not possible to have $_POST as null !! as you've written name="username" , name="password" name="etc" in your input tags. so when you SIMPLY do print_r($_POST); you should get post array something username = "" password = "" etc but as you've posted var_dump($_POST) is null has does't make any sense or not possible. Please justify yourself :) – Shashank Shah Mar 07 '16 at 12:47
  • Possible duplicate of [PHP POST not working](http://stackoverflow.com/questions/9914979/php-post-not-working) – Davis Mar 07 '16 at 14:46
  • @ Shashank Shah var_dump(file_get_contents("php://input")); is ok.but var_dump($_POST) is array(0)..It did happen. – sands.yu Mar 08 '16 at 01:28

1 Answers1

0

It is not possible to have var_dump($_POST) is null!

AS when you do

$username = $_POST['username'];
$password = md5($_POST['password']);
$verify = $_POST['verify'];
$session_verify = $_SESSION['verify'];
var_dump($_POST);

You'll get

array(3) { ["username"]=> string(8) "shashank" ["password"]=> string(8) "password" ["verify"]=> string(3) "123" }

If you pass username,password and verify blank even! enter image description here

 var_dump($_POST); 

will be

array(3) { ["username"]=> string(0) "" ["password"]=> string(0) "" ["verify"]=> string(0) "" }

so as you've posted var_dump($_POST) is null has does't make any sense or not possible.

Funny Edit :)

It is only possible when you type username as null password as null etc will produce

array(3) { ["username"]=> string(4) "null" ["password"]=> string(4) "null" ["verify"]=> string(4) "null" } 
Shashank Shah
  • 2,077
  • 4
  • 22
  • 46
  • var_dump(file_get_contents("php://input")); is ok.but var_dump($_POST) is array(0)!!!array(0)!!! ..It did happen. – sands.yu Mar 08 '16 at 01:29