index.php中显示多个未定义的索引

index.php中显示多个未定义的索引,php,Php,我正在学习使用php制作动态网页。我通过教程创建了我的网站。除了我的index.php页面上不断出现以下行之外,它工作得非常出色: 注意:未定义索引:第6行C:\xampp\htdocs\janewoo\u new\index.php中的页面 注意:未定义索引:第8行C:\xampp\htdocs\janewoo\u new\index.php中的页面 注意:未定义索引:第10行C:\xampp\htdocs\janewoo\u new\index.php中的页面 以下是我在index.php上

我正在学习使用php制作动态网页。我通过教程创建了我的网站。除了我的index.php页面上不断出现以下行之外,它工作得非常出色:

注意:未定义索引:第6行C:\xampp\htdocs\janewoo\u new\index.php中的页面 注意:未定义索引:第8行C:\xampp\htdocs\janewoo\u new\index.php中的页面 注意:未定义索引:第10行C:\xampp\htdocs\janewoo\u 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。希望有人能帮助我。非常感谢。

要更正警告更改:

if($_GET['page']=="traditional_teampage.html"){
成为:

if(isset($_GET['page']) and $_GET['page']=="traditional_teampage.html"){

也考虑这样的结构

的一个开关/case语句

甚至是一个简单的
数组()
白名单

if(isset($_GET['page']) and in_array($_GET['page'],array(
  'traditional_teampage.html',
  'traditional_teampage.html',
  'traditional_mediapage.html',
  'traditional_faqpage.html',
  'traditional_casepage.html',
  'consumer-proposal.html',
  'bankruptcy.html',
  'community.html',
  'traditional_contactpage.html'
)))
{
  include('includes/' . $_GET['page']);
}
else
{
  include("includes/traditional_home.html");
}

我的眼睛在流血!请缩进您的代码;(您需要检查<代码> ISSET($yGET [页])< /COD>无处不在,而不只是一次。还考虑使用Switt语句而不是其他许多IFS。请从中学习。<代码> }否则(ISSET($yGET [页])= =“消费者建议.html”){注意这一行不正确谢谢你的帮助,斯库齐。我把你的代码放进了文件中,但是有一个错误:解析错误:语法错误,在第17行的C:\xampp\htdocs\janewoo_new\index.php中出现意外的“{”。第17行是{include('includes/'.$\u GET['page']);}注意:我使用了你的数组代码。很抱歉没有足够的右括号,请重试,我已更改
))
斯库奇,你太棒了。我用了你的两个代码,现在两个都很好用。也谢谢你的链接。我将进一步研究它们。我是php新手,但我非常喜欢它。整洁,请接受你问题的答案(绿色勾选):)
if(isset($_GET['page']) and in_array($_GET['page'],array(
  'traditional_teampage.html',
  'traditional_teampage.html',
  'traditional_mediapage.html',
  'traditional_faqpage.html',
  'traditional_casepage.html',
  'consumer-proposal.html',
  'bankruptcy.html',
  'community.html',
  'traditional_contactpage.html'
)))
{
  include('includes/' . $_GET['page']);
}
else
{
  include("includes/traditional_home.html");
}