简体   繁体   English

如果没有验证问题,则在提交或发布到另一个页面后验证和显示问题的简单 PHP 表单

[英]Simple PHP Form that Validates and Display Issues after Submitting or Post to Another Page if No Validation Issues

I am new to PHP coding, and am struggling to get an answer.我是 PHP 编码的新手,正在努力寻找答案。

I need a simple php file for collecting and validating 3 variables: (1) Reference Number (Text) (Required) (2) Amount (Decimal) (Required) (3) E-Mail (Text) (Required) (4) Accept Terms and Conditions (Checkbox) (Required - Must be on)我需要一个简单的 php 文件来收集和验证 3 个变量:(1)参考编号(文本)(必需)(2)金额(十进制)(必需)(3)电子邮件(文本)(必需)(4)接受条款和条件(复选框)(必需 - 必须打开)

The fields should be validated upond pressing the Submit button.字段应在按下提交按钮后进行验证。 If there's any validation issues it needs to stay on the same form and point out the fields that cannot be validated / reasons.如果有任何验证问题,它需要保留在同一表单上并指出无法验证的字段/原因。 If however the fields are in order and all are entered, after pressing the submit button, the values should be posted in another form.然而,如果字段是有序的并且全部输入,则在按下提交按钮后,值应以另一种形式发布。

If anyone can help or give me advice?如果有人可以帮助或给我建议?

You can use javascript form validation or ajax, both can be incorporated into php code.您可以使用 javascript 表单验证或 ajax,两者都可以合并到 php 代码中。 To send value from one page to another php provides GET and POST methods.要将值从一个页面发送到另一个 php 提供了 GET 和 POST 方法。

I ran into this same issue.我遇到了同样的问题。 I would like to know about this as well.我也想知道这件事。 All of these down votes are not required.不需要所有这些反对票。

I think htmlspecialchars($_SERVER["PHP_SELF"]) is one of the tools to do this.我认为htmlspecialchars($_SERVER["PHP_SELF"])是执行此操作的工具之一。 I am not sure as I am new as well.我不确定,因为我也是新人。 I am trying to use that and isset($_POST['fname']) in the value field that doesn't seem to work either.我正在尝试在似乎不起作用的值字段中使用它和isset($_POST['fname'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM