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>

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);