Simple form not sending data via _POST(不通过 _POST 发送数据的简单表单)
问题描述
哇,这太尴尬了.这应该是另一种无聊的网络表单.我以前做过很多,但出于某种原因,这个特定的人不想合作.我是不是错过了什么?几个小时以来,我一直试图弄清楚这一点.我发誓我已经尝试排除所有问题,但没有任何运气.
基本上,我试图通过 $_POST 发送到 PHP 文件.最终我将使用 AJAX,但现在我什至无法将愚蠢的事情发送到 POST.因此,当您单击提交时,它会转到正确的页面.但是我收到一个错误未定义的索引(然后指向我称之为 $_POST 变量的行).我已经注释掉了 PHP 端的所有内容(signup1.php),所以现在它所做的只是 var_dump($_POST);
所以我可以看到数据并且它没有从 _POST 得到任何东西,愚蠢的事情是空的.我真的认为问题出在 HTML 方面.我会准确地发布我的代码.它有很多用于样式和布局目的的额外 div.我将所有这些都保留在那里,以防万一这是错误的原因,也许你们中的一个人会知道.另外,你可能会注意到我正在使用引导程序.也许那是什么? 我以前使用过引导程序作为表单并且它有效,但谁知道呢.
</表单>
如果有人有任何想法,请告诉我.我正在拔头发.我想我会因为查询数据库的问题而彻夜难眠,或者弄乱 AJAX 以使其完善,但我什至无法通过提交 RAW 数据的表单!非常令人沮丧.我希望有人能看到这个问题.
为了记录,这是我在表单重定向到 signup1.php 后的确切信息(是的,它转到了正确的页面).在 PHP 上,我所做的只是整个 $_POST 变量的 Var_dump.
var_dump($_POST);
它向我展示了这一点:
array(0) { }
您应该将 name 属性添加到表单字段中.
例如:
Wow, so this is embarrassing. This is just supposed to be another boring web form. I have done plenty before, but for some reason this specific one doesn't want to cooperate. Am I somehow missing something? I have been trying to figure this out for hours. I swear I have tried troubleshooting everything, without any luck.
Basically, I am attempting to send via $_POST to a PHP file. Eventually I will use AJAX, but right now I can't even get the stupid thing to POST. So when you click submit, it goes to the correct page. But i get an error "Undefined Index (then points to the line that I call my $_POST variable). I have commented out everything on the PHP side (signup1.php) so that now all it does is var_dump($_POST);
so I can see the data and it isnt getting anything from _POST, the stupid thing is empty. I really think the problem is on the HTML side. I will post my code exactly. It has a ton of extra divs for styling and layout purposes. I am going to keep all of that in there just in case that is the cause of the error, maybe one of you will know. Also, you may notice I am using bootstrap. Maybe that is something? I have used bootstrap for forms before and its worked, but who knows.
<form action="actions/signup1.php" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" class="form-control" placeholder="John Smith">
</div>
</div> <!-- end of name input column -->
<div class="col-md-6">
<div class="form-group">
<label for="phone">Phone Number:</label>
<input type="text" id="phone" class="form-control" placeholder="801-321-9876">
</div>
</div> <!-- end of phone number input column -->
</div> <!-- end of first .row of inputs -->
<div class="row">
<div class="col-md-6 column-sm-12">
<div class="form-group">
<label for="email">Email Address:</label>
<input type="text" id="email" class="form-control" placeholder="johnsmith@me.com">
</div>
</div> <!-- end of email address input column -->
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="city">City:</label>
<select id="city" class="form-control">
<option>Las Vegas</option>
<option>Salt Lake City</option>
<option>I'll Choose a Default Later...</option>
</select>
</div>
</div> <!-- end of city dropdown -->
<div class="col-md-3 col-sm-6">
<div class="form-group">
<label for="type-of-phone">Type of Phone:</label>
<select id="type-of-phone" class="form-control">
<option>iPhone</option>
<option>Android</option>
<option>Windows Phone</option>
<option>Blackberry</option>
<option>Other Cellphone</option>
<option>Landline</option>
</select>
</div>
</div> <!-- end of Smartphone Question Dropdown -->
</div> <!-- end of second .row of inputs -->
<div class="row">
<div class="col-md-12"><input type="submit" value="Submit"></div>
</div>
</form>
If anyone has any idea please let me know. I am pulling my hair out. I figured I would be up all night with problems having it querying the database, or messing with the AJAX to make it polished, but instead I can't even get past the form submitting the RAW data! Very frustrating. I hope someone out there can see the issue.
For the record this is my exactmessage after the form redirects to the signup1.php (yes it goes to the right page). On the PHP all i do is a Var_dump of the whole $_POST variable.
var_dump($_POST);
And it shows me this:
array(0) { }
You should be adding the name attribute to the form fields.
For example:
<input name="phone" type="text" id="phone" class="form-control" placeholder="801-321-9876">
这篇关于不通过 _POST 发送数据的简单表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:不通过 _POST 发送数据的简单表单
基础教程推荐
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01