Hello All

I am trying to just test a simple javascript code.
Following Code is working very fine in FF-14, Google Chrome - 21, Safari - 3.2

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript">
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.
   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.

if(isset($_GET['error'])) { 
   echo 'Error Logging In!';


<body><form action="process_login.php" method="post" name="login_form">
   Email: <input type="text" name="email" /><br />
   Password: <input type="password" name="password" id="password"/><br />
   <input type="button" value="Login" onclick="formhash(this.form, this.form.password);" />

Where I am wrong...? Please guide me.

Recommended Answers

All 9 Replies

in internet explorer check the activex object settings

Thank you Rithish for consideration. Can you be bit more specific

What error do you get? In IE, open developers tools (F12), go to the Script tab and start debugging.

var p = document.createElement("input");

What do you mean by:

p.name = "p";


What do you mean by:
p.name = "p";

I think he is sending the password as 'p' (name of the input), and the password input goes blank.

Are you sure that your external JS file (sha512.js) contains functions that compatible with IE as well? I don't know what hex_sha512() does, so it is hard to say what causes it to stop working... What does IE error say? At least it may help you find the incorrect call (format) for IE.

Hello to All and thank you all for considering my problem.
I want a login form in php with MySQL and session with password encryption mechanism.

For this I am trying this example

I am not getting error but the code actually just creating a blank textbox in IE and appending them one after another. And p is the object which will hold the reference of newly created textbox at runtime which will hold the hashed value of password. Here you can find the complete algorithm of hashing algorithm sha512

OK I found the solution.

Its actually more an IE thing. IE doesn't like to change the type property of inputs once they've been appended to the document. The simple fix would be to just swap around the appendchild() call so it comes after the property settings.
Quoted Text Here

p.name = "p";
   p.type = "hidden"
   p.value = hex_sha512(password.value);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.