The second, third and fourth elements take the email, password and confirmation password respectively: <td><div align="left">Email</div></td> <td><input name="email" type="text" size="40"></td> </tr> <tr> <td><div align="left">Password</div></td> <td><input name="pw1" type="password" size="40"></td> </tr> <tr> <td ><div align="left">Confirm Password </div></td> <td><input name="pw2" type="password" size="40"> Notice the hidden input; that has the name as the key. This element will act as the check point when form data is processed later on. We are using this element instead of the usual submit button because it provides a more portable way of submitting form values: <input type="hidden" name="key" /></td> </tr> <tr> <td></td> <td> <input name="submit" type="submit"></td> </tr> </table> As an added layer of security and for the convenience of the user, JavaScript code is made available to ensure that all form fields are filled in: function checkform(pform1){ if(pform1.uname.value==""){ alert("Please enter a username") pform1.uname.focus() return false } if(pform1.email.value==""){ alert("Please enter a email address") pform1.email.focus() return false } if(pform1.pw.value==""){ alert("Please enter a password") pform1.pw.focus() return false } if(pform1.pw.value=="" && pform1.uname.value==""&& pform1.email.value==""){ alert("Please make sure that you have entered all the information that is required") return false } return true } </script> In the code above, the pform1 refers to the form name and the pw refers to the form field name. The same applies to the uname.value and email.value lines. The alert message is what the user will see if the form fields are empty. Conclusion In this article we looked in detail at the user registration script. In the next article we will discuss database security and also look at password management.
blog comments powered by Disqus |
|
|
|
|
|
|
|