2013-01-09 15 views
-1

在我的PHP文件名爲「account.php」我有配藥文本在PHP

<?php 
// First we execute our common code to connection to the database and start the session 
require("common.php"); 
// 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"); 
}   
?> 
<html> 
<body> 
    <link rel="icon" type="image/gif" href="favicon.gif" /> 
    <?php include("header.php"); ?> 
    <div id="main-box"> 
     <ul> 
      <li class="buttons"> 
<?php 
//TEXT BOX WITH A LINE FROM **TEXT.txt** SHOULD APPEAR HERE AFTER USER CLICKS BUTTONS 
?> 
       <input type="button" name="account" value="Get Your Account" onclick="#" /> 
      </li> 
     </ul> 
    </div> 
</body> 
</html> 

我想它,以便當用戶點擊該按鈕,一個文本框出現,並顯示在文本文件中的一行,並當他們查看它時,它會從文本文件中刪除它。 的text.txt

Eddie so after the user clicks the button it displays this line to them and then deletes it after so that the next line would then become the first line. 
Apples 
Hello 
People 

如果你不明白我的問題,那麼請讓我知道,我會嘗試進一步解釋。謝謝。 :)

+2

PHP在被髮送到瀏覽器之前被解析。如果您希望通過按鈕與用戶交互,則需要客戶端腳本(如JavaScript)。 –

+0

我已更新我的問題,嘗試使其更易於理解。 – Purps

回答

0

我的建議是使用JavaScript(或jQuery)對處理文本文件讀取的PHP腳本進行AJAX調用,然後刪除頂部行。然後JavaScript將需要腳本的響應(文本文件中的行)並將該文本框添加到頁面。