dongyukang7006 2016-03-17 21:08
浏览 125
已采纳

清空$ _POST。 值最终以$ GLOBAL结尾

I have been struggling with a strange $_POST problem since i reinstalled my OS. I have decided to return working on one of my free time projects and I have noticed that all of my POST requests are not working, but I'm sure they have worked before.

What i noticed is that all the $_POST values always end up in $GLOBALS instead and $_POST array is always empty. Any ideas?

Using PHP Version 5.6.19

php.ini:

https://dl.dropboxusercontent.com/u/42704655/php.ini

Script:

    $('#login-form').on('submit', function () {
    $.ajax({
        type: "POST",
        url: "php/login.php",
        data: $("#login-form").serialize(),
        success: function (data) {
    });

    return false;
});

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/login.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" async></script>
    <script src="scripts/login-script.js" async></script>
</head>
<body>
<div id="wrapper">
    <div id="login">
        <form method="post" id="login-form" action="php/login.php">
            <table>
                <tr>
                    <td>Login:</td>
                    <td><input type="text" name="login" form="login-form" class="input" autofocus></td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="password" form="login-form" class="input"></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <button type="submit" form="login-form">Login</button>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" id="input-td">
                        <p id="errorMsgs"></p>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

</body>
</html>

PHP

<?php
print_r($_POST);

$GLOBALS ('test1' as login, 'test2' as pw)

array(8) { ["HTTP_RAW_POST_DATA"]=> string(26) "login=test1&password=test2" ["_GET"]=> array(0) { } ["_POST"]=> array(0) { } ["_COOKIE"]=> array(0) { } ["_FILES"]=> array(0) { } ["GLOBALS"]=> *RECURSION* ["login"]=> string(0) "" ["pass"]=> string(0) "" }
  • 写回答

1条回答 默认 最新

  • dpi9530 2016-03-17 22:10
    关注

    I think i have just figured it out. It's my webserver build in into the IDE that has some bugs. https://intellij-support.jetbrains.com/hc/en-us/community/posts/206999125-PhPStorm-10-does-not-allow-POST-method

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法