如何散列<input />类型密码?

时间:2014-02-02 17:08:35

标签: javascript html hash hashcode

我有一个JavaScript函数,应该创建一个新的登录表单,然后提交表单。但由于某种原因,该函数没有向PHP文件提交任何内容。功能是正确还是我在这里做错了什么?

使用Javascript:

function passval() {
    var email = document.getElementById("loginEmail").value;
    var passv = document.getElementById("loginPass").value;
    alert (email + passv);
    // Create a new element input, this will be our hashed password field. 
    var f = document.createElement("form");
    f.setAttribute('method',"post");
    f.setAttribute('action',"../ru/login/ajax/loginchk.php");
    var p = document.createElement("input");
    var email = document.createElement("input");
    alert (p + email)
    // Add the new element to our form. 
    f.appendChild(p);
    p.name = "p";
    p.type = "text";
    p.value = hex_sha512(passv.value);
    alert (p.value);
    f.appendChild(email);
    emai.name = "emailadd";
    emai.type = "text";
    emai.value = email;
    alert (emai.value);
    password.value = "";
    email = "";
    //submit the form.
    f.submit();
}

HTML

<form id="login" method="post" action="">
    <a href="#" id="flipToRecover" class="flipLink">Forgot?</a>
    <input type="text" name="loginEmail" id="loginEmail" value="Email" />
    <input type="password" name="loginPass" id="loginPass" value="pass" />
    <input type="submit" id="submit" name="submit" value="Login" onclick="passval()"  />
</form>

0 个答案:

没有答案