我正在为一个班级制作一个网页。这是一个为即将到来的新生设计的网站,用于接收他们感兴趣的专业的信息。
对于作业,我必须将我的原始 HTML 代码分成 header.php、content.php 和 footer.php。我还必须通过 $ SERVER[PHP SELF] 的操作为我的表单使用 POST 方法。我还必须在表单中使用隐藏的输入字段。
我已经完成了所有这些任务,但我认为我的 heredoc 打印有问题 <<
我知道我的表单还有一些工作要做,但我真的很想看到页面将正确加载我的页眉、内容和页脚。由于我什么都看不到,我不想继续写出任何其他功能。请您看看我的 PHP 代码并帮我找到这个错误好吗?我确定我只是忽略了一些东西,但我会很感激你的帮助!谢谢!
头文件.php:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UNA Preview Day 2013</title>
<link rel="stylesheet" href="preview.css">
<script src="preview.js"></script>
</head>
<body>
内容.php:
<!-- Tell script impaired users we *must* have Javascript -->
<noscript>
<p class="alert">Sorry, this page requires Javascript!</p>
</noscript>
<img src= "banner.gif" alt = "UNA Logo" />
<br />
<h1>UNA Preview Day 2013</h1>
页脚.php
<div class = "image">
<img src = "unapic.png" alt = "UNA Logo" />
</div>
<p id = "footer">Copyright © 2013 | University of North Alabama</p>
</body>
</html>
索引.php:
<?PHP
require("header.php");
if ($_POST[_submit_check]) {
processForm();
}
else {
displayForm();
}
function displayForm() {
require("content.php");
}
require("footer.php");
if (array_key_exists('_submit_check', $_POST)) {
processForm();
}
else {
displayForm();
}
// ------------------------------------------------
function processForm() { //NEEDS WORK
print "Hello, $_POST[user]!";
}
function display_form() {
//require("content.php");
print <<<HTMLBLOCK
<html>
<head>
<title>UNA Preview Day 2013</title>
</head>
<body>
<form name = "contact" method = "POST" action="$_SERVER[PHP_SELF]">
<div class = "appearance">
*All fields required.*<br /><br />
Name: * <input title="Name required!" type = "text" id = "name" name = "name" required autofocus onchange = "validName();" size = 30>
<br />
Email: * <input title="Email address of form username@domain required!" type = "email" placeholder = "me@example.com" id = "email" name = "email"
required onchange = "validAddress();" size = 30>
<br /><br /><br />
Areas of Study <br />
Check the program(s) in which you are interested in. (*Check AT LEAST one.*) <br />
<input type = "checkbox" id = "cs" name = "option[]">Computer Science<br />
<input type = "checkbox" id = "cis" name = "option[]">Computer Information Systems<br />
<input type = "checkbox" id = "ddep" name = "option[]">Dual Degree Engineering Program<br /><br /><br />
<div class = "center">
<input type="button" value="Send" onClick = "return validOption()">
<input type="reset" value="Clear">
</div>
<input type = "hidden" name="_submit_check" value="1">
</div>
<br />
<br />
</form>
</body>
</html>
HTMLBLOCK;
}
?>