php - html表单发布给出空数组

标签 php html arrays post

我正在尝试将 html 表单中的数据(html 代码在 index.php 文件中)发布到 add_student.php 文件中,该文件应该只打印 $_POST使用 print_r 的数组功能。但是结果总是空数组。

index.php

<html>

<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/styles.css">
    <link rel="stylesheet" href="css/font-awesome.css">
</head>
<body>

<div class="contact col-md-12" id="get_in_touch">
    <div class="col-md-10 col-md-offset-1">
        <div class="contact_title">
            <h2>
                Add a student
            </h2>
        </div>
        <div class="contact_container">
            <div class="contact_form col-md-8">
                <form action="add_student.php" method="post">
                    <input name="student_name"   type="text"  placeholder="FULL NAME" class="input1"/>
                    <input name="student_email"  type="text"  placeholder="E-MAIL" class="input1"/>
                    <input name="password"  type="text"  placeholder="PASSWORD" class="input1"/>
                    <input name="major"  type="text"  placeholder="MAJOR" class="input1"/>
                    <input name="group"  type="text"  placeholder="GROUP NUMBER" class="input1"/>
                    <input name="submit"  type="submit" value="ADD STUDENT"/>
                </form>
            </div>
        </div>
    </div>
</div>

</body>

add_student.php:

<?php
print_r($_POST);
?>

为什么我总是得到空数组?

最佳答案

看来问题出在 PHPStorm localhost 端口。当您只需在浏览器中输入 index.php 的地址时,它就可以完美运行。但是,当我从 IDE 运行代码时,它返回空数组。

关于php - html表单发布给出空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35927994/

相关文章:

java - 数组中的数据结构 NullPointerException

Yii 中的 phpass 身份验证失败

php - 仅当文件存在于 PHP 中时如何包含文件?

html - 如何使用网格结构嵌入视频?

c++ - 如何将数组复制到更大的数组并将零添加到未使用的空间? C++

c - int数组到c中的字符串

PHP MySQL + 基于表单选择创建搜索查询

php - 当有多少表时如何选择查询

javascript - 如何使用 jQuery 在底部 div 设置按钮

javascript - Bamboo 建图生成