2014-05-01 42 views
0

div標籤,我有這樣的代碼:錯誤消息在HTML代碼

... 
      header("Location: private.php"); 
      die("Redirecting to: private.php"); 
     } 
     else 
     { 
      print("Login Failed."); >>I WANT MOVE THIS IN DIV TAG<< 
.... 

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<title>Untitled Document</title> 
<link rel="stylesheet" type="text/css" media="screen" href="css/style.css"> 
</head> 
<body> 
    <div id="container"> 
     <div id="header-main">Main Menu</div> 
     <div id="header"></div> 
     <div id="content"> 
      <div class="table"> 
       <div class="tr"> 
        <div id="member" class="td" align="center"> 
         <span class="member">Data</span> 
        </div> 
        <div class="vr">&nbsp;</div> 
        <div id="login" class="td"> 
        <div class="login-error"> **>>> HERE ERROR MESSAGE <<<** </div> 
        <div class="login-title">LogIn</div> 
         <form action="login.php" method="post"> 
          <input type="text" name="username" value="<?php echo $submitted_username; ?>" placeholder="Username" autofocus/> 
          <br /><br /> 
          <input type="password" name="password" value="" placeholder="Password"/> 
          <br /><br /> 
          <input type="submit" value="Login" /> 
                </form> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</body> 
</html> 

我怎樣才能解決這一問題?

+0

在變量中添加消息並在所需行中使用該消息。 – Rikesh

+2

'echo'

Login Failed
';'??? – Karuppiah

回答

1
$errorMessage = null; 

else{ ... 
      $errorMessage = "Login Failed."; 
     .... 


in html >>> 
<?php if(!empty($errorMessage)) ?> 
<div class="login-error"><?php echo $errorMessage;?></div> 
+0

非常感謝。代碼真的有用!再次感謝! –