Add User Form - Confirm password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Add User Form - Confirm password

Post 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.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Add User Form - Confirm password

Post 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.
mehran
Forum Newbie
Posts: 17
Joined: Fri Jan 21, 2011 1:31 am

Re: Add User Form - Confirm password

Post 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;
}
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Re: Add User Form - Confirm password

Post by weblearner »

hey klevis miho, mehran

thanks for helping, had tried both methods.
Post Reply