我正在研究基于文本的在线游戏(这是非常不完整的),并且我主要使用PHP。在我的HTML中,我有一个用于我的游戏命令的表单(文本输入),但它不会显示。这是我的HTML:HTML表单中的文本输入不会显示
include_once 'game.php';
?>
style="width: 600; position: absolute; bottom: 0; z-index: 2;">
$input = $_POST["input"];
?>
所以这是真正的FORM和INPUT螺丝我,因为它没有出现。我也有这个作为我的CSS,如果它可以帮助:
.main {
width: 600px;
height: 400px;
background-color: white;
border: 1px solid black;
position: absolute;
top:0;
left: 0;
right: 0;
z-index: 1;
}
.container {
width: 602px;
height: 500px;
background-color: white;
border: 1px solid blue;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 0;
margin: 0 auto;
}
当然,我有我的game.php,但我不认为这是个问题。
任何帮助,将不胜感激。
编辑:根据人们的答案,这可能是PHP。这里是game.php文件的完整代码,我不知道什么是错的。
include_once 'index.php';
$World = simplexml_load_file("gameworld.xml");
$CurrentPos = 0;
$Done = 0;
print "
";
printplace();
function printplace() {
GLOBAL $World, $CurrentPos;
$Room = $World->ROOM[$CurrentPos];
$Name = $Room->NAME;
$Desc = wordwrap((string)$Room->DESC);
print "$Name
";
print str_repeat('-', strlen($Name));
print "
$Desc
";
if ((string)$Room->NORTH != '-') {
$index = (int)$Room->NORTH;
print "North: {$World->ROOM[$index]->NAME}
";
}
if ((string)$Room->SOUTH != '-') {
$index = (int)$Room->SOUTH;
print "South: {$World->ROOM[$index]->NAME}
";
}
if ((string)$World->ROOM[$CurrentPos]->WEST != '-') {
$index = (int)$Room->WEST;
print "West: {$World->ROOM[$index]->NAME}
";
}
if ((string)$World->ROOM[$CurrentPos]->EAST != '-') {
$index = (int)$Room->EAST;
print "East: {$World->ROOM[$index]->NAME}
";
}
print "
";
}
while (!$Done) {
print "
"; // add another line break after the user input
$input = split(' ', $input);
switch(trim($input[0])) {
case 'north':
if ((string)$World->ROOM[$CurrentPos]->NORTH != '-') {
$CurrentPos = (int)$World->ROOM[$CurrentPos]->NORTH;
printplace() ;
} else {
print "You cannot go north!
";
}
break;
case 'south':
if ((string)$World->ROOM[$CurrentPos]->SOUTH != '-') {
$CurrentPos = (int)$World->ROOM[$CurrentPos]->SOUTH;
printplace() ;
} else {
print "You cannot go south!
";
}
break;
case 'west':
if ((string)$World->ROOM[$CurrentPos]->WEST != '-') {
$CurrentPos = (int)$World->ROOM[$CurrentPos]->WEST;
printplace() ;
} else {
print "You cannot go west!
";
}
break;
case 'east':
if ((string)$World->ROOM[$CurrentPos]->EAST != '-') {
$CurrentPos = (int)$World->ROOM[$CurrentPos]->EAST;
printplace() ;
} else {
print "You cannot go east!
";
}
break;
case 'look':
printplace() ;
break;
case 'quit':
$Done = 1;
break;
}
}
print "
Thanks for playing!
";
?>
2015-08-25
dumpong
+0
如果去掉'包括( 'game.php')'没有问题消失? –
+1
当我加载你的网页时,它钉住了我的CPU。 –
+0
是的,那也是我的想法。虽然我不确定。当我上次尝试时,它没有得到任何结果。 –