2
<?php
ob_start();
// First we execute our common code to connection to the database and start the session 
define('MyConst', TRUE);

include('../database.class.php');
include('../table.class.php'); 
include('../user.class.php');
include('../loginattempts.class.php');
include('../timer.class.php');
include('../characters.class.php');
include('../weapontype.class.php');
include('../objects/weapons/weaponobject.class.php');
include('../objects/weapons/bowieknife.class.php');
include('../npc/enemy.class.php');
include('../npc/skinhead.class.php');
include('../npc.class.php');
include('../npctype.class.php');
include('../functions.php');
include('../loginf.php');  
include('locationf.php');

$dbo = database::getInstance();
$dbo -> connect("***************", "********", "********", "***************", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); 

secSessionStart();

// At the top of the page we check to see whether the user is logged in or not 
if(empty($_SESSION['user'])) 
{ 
    // If they are not, we redirect them to the login page. 
    header("Location: login.php"); 

    // Remember that this die statement is absolutely critical.  Without it, 
    // people can view your members-only content without logging in. 
    die("Redirecting to login.php"); 
}

$_SESSION['currentlocation'] = "combat.php";
?>
<?php
if($_POST['formSubmit'] == "Submit") 
{
$varMovie = $_POST['formMovie'];

 echo $varMovie;
}
?>

<!DOCTYPE html>
<html>
<head> 
</head>
<body>


<form action="index.php" method="post">

Which is your favorite movie?
<input type="text" name="formMovie" maxlength="50">

<input type="submit" name="formSubmit" value="Submit">

</form>
</body>
</html>    

好的...所以它应该回显一些文本。相反,它只是重新加载表单!我不确定还要写什么,而且它不允许我发帖,所以我只会重复我写的内容,直到达到限制。

4

2 回答 2

0

在 HTML 中添加一个 ELSE 部分,它将显示表单或答案,但保持标题等完整。

<!DOCTYPE html>
<html>
<head> 
</head>
<body>

<?php
if($_POST['formSubmit'] == "Submit") 
{
$varMovie = $_POST['formMovie'];

 echo $varMovie;
}
else {
?>

<form action="index.php" method="post">

Which is your favorite movie?
<input type="text" name="formMovie" maxlength="50">

<input type="submit" name="formSubmit" value="Submit">

</form>
<?php } ?>
</body>
</html>    
于 2013-06-18T23:17:28.063 回答
0

我倾向于使用:

<?php
if (array_key_exists("formSubmit",$_POST) && !strcmp($_POST["formSubmit"],'Submit'))
{
  $varMovie = $_POST['formMovie'];

  echo "Movie=(${varMovie})<br>\n";
}
:
:

还要注释掉上面的所有包含等,检查它是否为您提供了 formMovie 的内容,然后逐渐添加其他内容,直到它失败(或不失败)。干杯。

于 2013-06-18T23:54:20.220 回答