Page 1 of 1

Add User Form - Confirm password

Posted: Wed Jan 26, 2011 12:22 am
by weblearner
Hi all

Am doing a php form to add user and the code as below:

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Staff Name:</td>
<td><input type="text" name="STAFFNAME" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Username:</td>
<td><input type="text" name="USERNAME" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="password" name="USERPASSWORD" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Confirm Password</td>
<td><input name="CFMPW" type="password" id="CFMPW" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Add User" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form></td>

The mysql table has these fields:

USER_ID, STAFFNAME, USERNAME, USERPASSWORD


Problem is that how can i implement the 'confirm password' on the form to check on the password keyed by user.
Would greatly appreciate if anyone could give me some pointers. Thanks.

Re: Add User Form - Confirm password

Posted: Wed Jan 26, 2011 3:38 am
by klevis miho
You should add some javascript that checks the password confirmation.
Then to be absolutely sure that the password confirmation is the same as the password, do a php check on the server, in case the user turns disables javascript on his browser.

Re: Add User Form - Confirm password

Posted: Wed Jan 26, 2011 6:02 am
by mehran
first of all use php builtin fuction wordwrap ,asign it to a variable,then explode that variable,explode is also php fuction,which make an array of it,
then using the foreach loop to compare each word with each other,
like
$newtext = wordwrap( here is the text field value, 1, "/", 1);
$array1 = explode('/',$newtext);
repeat the above process for 2nd array
$i=0;
foreach($array1as $a){
if($a==$array2[$i]){
$meh=$meh+1;
}
$i = $i + 1;
}

Re: Add User Form - Confirm password

Posted: Fri Jan 28, 2011 4:30 am
by weblearner
hey klevis miho, mehran

thanks for helping, had tried both methods.