试图测试我的帖子表单(调试) [英] Trying to test my post form (debugging)

查看:107
本文介绍了试图测试我的帖子表单(调试)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,我正在检查它是否正确提交。这是我第一次进入POST,所以除了基本的研究和教程之外,我遇到了很多问题。我写了一个简单的脚本来查看我的表单是否正常工作。 HTML被裁剪只显示你的表单;我确实有一个验证和所有这些。



没有命名冲突,无论是文件名还是变量名,所以我认为这是一个语法错误,或者只是我是那个不知道发布任何东西的人。

以下是HTML:

 < HTML> 
< body>
名称:< br>< input type =textname =nametitle =您的全名style =color:#000placeholder =输入全名/>
< br>< br>
电子邮件地址:< br>< input type =textname =emailtitle =您的电子邮件地址style =color:#000placeholder =输入电子邮件地址/>
< br>< br>
如何提供帮助:< br>< textarea cols =18rows =3name =helptitle =您要提供的服务style =color:#000placeholder = 请让我们知道您可能需要协助的任何方式>< / textarea>
< br>< br>
< input type =submitvalue =Submitid = submitbox/>
< / form>
< / body>
< html>

以下是帖子(名为 postest ):

 <?php 
$ name = $ _POSTEST ['name'];
$ email = $ _POSTEST ['email'];
$ help = $ _POSTEST ['help'];

echo {$ name},{$ email},{$ help};
?>

这篇文章是从本教程

另外,我可能会问:我该怎么去(半)永久存储在电子表格中的信息,以供我稍后阅读?但是,这是一个次要问题。

你的问题的一部分是,当你真正想要的是$ _POST数组时,你正在使用一个你调用 $ _ POSTEST 的变量。$ _POST是一个特殊的重新存储(需要用这种精确的语法来引用):


传递给当前脚本的变量的关联数组通过
HTTP POST方法。


参考:PHP手册 - http://php.net/manual/en/reserved.variables.post.php



因此,无论您输入PHP脚本的输入名称和值是否通过HTTP POST进入,它们都将位于$ _POST数组中。



因此,使用你的例子,它会是:

 <?php 
$ name = $ _POST ['名称'];
$ email = $ _POST ['email'];
$ help = $ _POST ['help'];

echo {$ name},{$ email},{$ help};
?>


I have a form, and I'm checking to see if it's submitting properly to post. This is my first foray into POST, so other than rudimentary research and tutorial stuff, I'm having a lot of problems. I wrote a simple script to see if my form is working properly at all. The HTML is clipped to only show you the form; I do have a validation and all that.

There is no naming conflict, whether in the filenames or those of the variables, so I assume it's a syntax error or just me being that guy with no knowledge of post whatsoever.

Here's the HTML:

<html>
 <body>
  <form name="Involved" method="post" action="postest.php" target="_blank">
   Name: <br><input type="text" name="name" title="Your full name" style="color:#000" placeholder="Enter full name"/>
   <br><br>
   Email: <br><input type="text" name="email" title="Your email address" style="color:#000" placeholder="Enter email address"/>
   <br><br>
   How you can help: <br><textarea cols="18" rows="3" name="help" title="Service you want to provide" style="color:#000" placeholder="Please let us know of any ways you may be of assistance"></textarea>
   <br><br>
   <input type="submit" value="Submit" id=submitbox"/>
  </form>
 </body>
<html>

Here's the post (named postest):

<?php
    $name   =   $_POSTEST['name'];
    $email  =   $_POSTEST['email'];
    $help   =   $_POSTEST['help'];

    echo {$name}, {$email}, {$help};
?>

This post was derived from this tutorial.

Also, I might as well ask: How would I go about submitting information to be (semi)permanently stored on a spreadsheet for my later perusal? However, this is a secondary question.

解决方案

Part of your problem is that you are using a variable you're calling $_POSTEST when really what you want is the $_POST array. $_POST is a special reserved variable in PHP (and needs to be referenced using that exact syntax) which is:

An associative array of variables passed to the current script via the HTTP POST method.

Reference: PHP Manual - http://php.net/manual/en/reserved.variables.post.php

So whatever input names and values you're passing into the PHP script come in via HTTP POST, and they'll be located in the $_POST array.

So using your example, it would be:

<?php
    $name   =   $_POST['name'];
    $email  =   $_POST['email'];
    $help   =   $_POST['help'];

    echo {$name}, {$email}, {$help};
?>

这篇关于试图测试我的帖子表单(调试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆