【发布时间】:2014-03-17 07:11:14
【问题描述】:
我正在学习使用 php 制作动态网页。我通过教程创建了我的网站。它工作得很好,除了以下几行不断出现在我的 index.php 页面上:
注意:未定义索引:第 6 行 C:\xampp\htdocs\janewoo_new\index.php 中的页面 注意:未定义索引:第 8 行 C:\xampp\htdocs\janewoo_new\index.php 中的页面 注意:未定义索引:第 10 行 C:\xampp\htdocs\janewoo_new\index.php 中的页面 ...
这是我在 index.php 上的代码:
<?php
include("includes/header.html");
include("includes/navbar.html");
if($_GET['page']=="traditional_teampage.html"){
include("includes/traditional_teampage.html" );
}else if($_GET['page']=="traditional_mediapage.html"){
include("includes/traditional_mediapage.html");
}else if($_GET['page']=="traditional_faqpage.html"){
include("includes/traditional_faqpage.html");
}else if($_GET['page']=="traditional_casepage.html"){
include("includes/traditional_casepage.html");
}else if(isset($_GET['page'])=="consumer-proposal.html"){
include("includes/consumer-proposal.html");
}else if($_GET['page']=="bankruptcy.html"){
include("includes/bankruptcy.html");
}else if($_GET['page']=="community.html"){
include("includes/community.html");
}else if($_GET['page']=="traditional_contactpage.html"){
include("includes/traditional_contactpage.html");
}else{
include("includes/traditional_home.html");
}
include("includes/footer.html");
?>
我按照其他人的答案中的描述放置了 isset() ,但是按钮都转到了同一页面的第一页。我更像是一个设计师而不是一个程序员,我正在尽我最大的努力学习 php。希望可以有人帮帮我。非常感谢。
【问题讨论】:
-
我的眼睛,在流血!请缩进你的代码;(
-
您需要检查
isset($_GET['page'])无处不在,而不仅仅是一次。还可以考虑使用 switch 语句而不是许多 else ifs。 -
请Use this instead学习。
-
}else if(isset($_GET['page'])=="consumer-proposal.html"){注意此行不正确
标签: php