使用标题(“Location:...”。如何传递数组变量? [英] Using header("Location:...". How to pass over array variable?

查看:87
本文介绍了使用标题(“Location:...”。如何传递数组变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个PHP脚本,可以进行一些表格输入验证。因为如果字段有不正确的数据,它会验证

每个字段,它会向$ $ $ b $ $ $数组附加一条错误消息。例如


if(an_error = true){

$ errors。="< tr>< td>你输入了一个姓氏。这是强制性日期

出生不正确。< / td>< / tr>" ;;

}


以前我总是把HTML错误页面代码包含在

相同的脚本中,但是现在我将它移出来使维护更容易。


验证时完成现在有一个声明说

if($ errors!=""){

header(" Location:./ error_page.php");

}


但是,如何将errors数组传递给error_page。我想要

能够单独列出每个错误。


如果这是一个愚蠢的简单问题,请原谅我。我只花了大约一个星期的时间来做



提前谢谢。


亲切的问候


Dave

Hi there,

I have a php script that does some form input validation. As it verifies
each field if the field has incorrect data, it appends an error message to
an $error array. E.g.

if (an_error = true) {
$errors.="<tr><td>You have note entered a surname. This is mandatory date
of birth incorrectly.</td></tr>";
}

Previously I had always had the HTML error page code contained within the
same script, but now I am moving it out to make maintenance easier.

When validation completes there is now a statement that says
if ($errors!="") {
header("Location: ./error_page.php");
}

However, how can I pass the errors array to the error_page. I want to be
able to list each error individually.

Forgive me if this is a silly easy question. I have only been doing PHP for
about a week.
Thanks in advance.

Kind regards

Dave

推荐答案

错误数组。例如


if(an_error = true){
error array. E.g.

if (an_error = true) {


errors。="< tr>< td>你有注意输入姓氏。这是强制性日期

出生不正确。< / td>< / tr>" ;;

}


以前我总是把HTML错误页面代码包含在

相同的脚本中,但是现在我将它移出来使维护更容易。


验证时完成现在有一个声明说

if(
errors.="<tr><td>You have note entered a surname. This is mandatory date
of birth incorrectly.</td></tr>";
}

Previously I had always had the HTML error page code contained within the
same script, but now I am moving it out to make maintenance easier.

When validation completes there is now a statement that says
if (


errors!=""){

header(")位置:./ error_page.php");

}


但是,如何将errors数组传递给error_page。我想要

能够单独列出每个错误。


如果这是一个愚蠢的简单问题,请原谅我。我只花了大约一个星期的时间来做



提前谢谢。


亲切的问候


Dave

errors!="") {
header("Location: ./error_page.php");
}

However, how can I pass the errors array to the error_page. I want to be
able to list each error individually.

Forgive me if this is a silly easy question. I have only been doing PHP for
about a week.
Thanks in advance.

Kind regards

Dave


这篇关于使用标题(“Location:...”。如何传递数组变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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