dso0139 2013-07-16 11:00
浏览 37
已采纳

PHP无法使用Post找到表单元素

I have 2 PHP files, login.php and register.php
I'm using sha512 encryption and using the login mechanism from the following site
Some of the registration code appears there, but I created the registration form and changed the written registration form the site to be `process_registration'

In login.php , the form is sent using : onclick="formhash(this.form,this.form.password);"
Here is the formhash(): (from forms.js)

function formhash(form, password) {
// Create a new element input, this will be out hashed password field.
var p = document.createElement("input");
// Add the new element to our form.
form.appendChild(p);
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}

So in order the registration and the login to have the same encryption process, the registration form should use this method as well, but when i get to process_registration.php with my form (and it gets there, with all the correct parameters) the p var doesn't exist in the POST although it exists in the login.php which is the exact same form and fields, except that the login uses process_login.php as its action and register.php uses process_registration.php as its action.

Here is the registration file form:

<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript" src="forms.js"></script>


<form action="process_registration.php" method="post" name="register_form">
Username : <input type="text" name="username" /><br />
Name : <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Password: <input type="password" name="password" id="password"/><br />
<input type="button" value="Register" onclick="formhash(this.form,this.form.password);" />
</form>
  • 写回答

1条回答 默认 最新

  • dongtang6718 2013-07-16 11:52
    关注

    Try this, to complete the creation and full definition of the new field before adding it to the DOM.

    var p = document.createElement("input");
    p.name = "p";
    p.type = "hidden";
    p.value = hex_sha512(password.value);
    // Add the new element to our form.
    form.appendChild(p);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化