header()with if / then语句 [英] header() with if/then statements

查看:82
本文介绍了header()with if / then语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个验证脚本来验证信息并将客户重定向到相应的错误页面。例如:


if($ FName =""){

header(''Location:/verify_fname.htm'');

}

else {

if($ LName =""){

header(''Location: /verify_lname.htm'');

}

else {

if($ Company =""){

header(''Location:/verify_company.htm'');

}

else {

if($ Title = "){

header(''Location:/verify_title.htm'');

}

}

}

}


代码的目的是检查变量。如果在变量中找到错误,则会重定向到正确的错误页面。否则,

继续通过else语句,然后检查另一个

变量,依此类推。最后的else语句重定向到一个

进程脚本,该脚本将所有信息写入表中。我收到这条错误消息:

无法修改标题信息 - 标题已经发送了


我不能放HTML之前的重定向,因为我希望重定向是

条件。任何帮助将不胜感激。

I have created a verification script to verify information and redirect
the customer to the appropriate error page. For example:

if ($FName=""){
header(''Location:/verify_fname.htm'');
}
else{
if ($LName=""){
header(''Location:/verify_lname.htm'');
}
else{
if ($Company=""){
header(''Location:/verify_company.htm'');
}
else{
if ($Title=""){
header(''Location:/verify_title.htm'');
}
}
}
}

The intent of the code is to check a variable. If an error is found in
the variable, it redirects to the correct error page. Otherwise, it
continues on through the else statement which then checks another
variable and so and so on. The final else statement redirects to a
process script that takes all the information writes it to a table. I
am getting this error message:
Cannot modify header information - headers already sent by

I can''t put the redirect before the HTML as I want the redirect to be
conditional. Any help would be appreciated.

推荐答案

FName =""){

header(' '位置:/verify_fname.htm'');

}

else {

if(
FName=""){
header(''Location:/verify_fname.htm'');
}
else{
if (


LName =""){

header(''Location:/verify_lname.htm'');

}

else {

if(
LName=""){
header(''Location:/verify_lname.htm'');
}
else{
if (


Company =""){

header(''Location:/verify_company.htm'') ;

}

else {

if(
Company=""){
header(''Location:/verify_company.htm'');
}
else{
if (


这篇关于header()with if / then语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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