gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 01:15:25 26 4
gpt4 key购买 nike

我正在尝试将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com