我正在开发一个使用 PHP 创建类似博客的网页的项目。我想在表单上方的屏幕上打印文本,但这似乎是不可能的,因为变量在$_GET
输入数据之前试图从表单中获取数据。是否可以将文本放在表单上方?
到目前为止,这是我的代码:(PHP通过将“basic.php”(文件名)放入标签的action
属性来更新屏幕)<form>
<!-- this file is called basic.php-->
<!DOCTYPE html>
<html>
<head>
<title>My Blog</title>
<style type = "text/css">
h2
{
color:#FF2312;
text-align:center;
font-family:Impact;
font-size:39px;
}
p
{
font-family:Verdana;
text-align:center;
color:#000000;
font-size:25px;
}
</style>
</head>
<body>
<?php
$subject=$_GET["msg"];//variable defined but attempts to get unentered data
?>
<i> <?php print $subject;//prints var but gets error message because $subject can't get form data ?></i>
<!--want to print text above form-->
<form name = "post" action = "basic.php" method = "get">
<input type = "text" name = "msg">
<input type = "submit">
</form>
</body>
</html>