matching passwords

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
Log2
Forum Newbie
Posts: 17
Joined: Sat Jan 08, 2005 6:04 pm

matching passwords

Post by Log2 »

Ok I want to know how i can make a duplicate of this:

Code: Select all

<tr>
<td>New Password:</td>
<td><input type="password" name="newpass" maxlength="30" value="
<? echo $form->value("newpass"); ?>"></td>
<td><? echo $form->error("newpass"); ?></td>
</tr>
so that it checks to see if the passwords are the same?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

care to explain a bit? I don't understand..

a note: writing out the value to a password field ends up completely unencrypted on the client's side. Additionally, I'd highly suggest removing the carriage return between value=" and <? as this can easily create an extraneous space or other characters in the password sent back.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You'll notice that nearly every registration script will avoid sending the password back to the client at all clients, unencrypted atleast, because of the fact of people lurking around.
Log2
Forum Newbie
Posts: 17
Joined: Sat Jan 08, 2005 6:04 pm

Post by Log2 »

removing the carriage return between value=" and <?
that's not actually there, i put that there to make it look neater. what i want is a similar form, or input whatever you want to call it, that confirms that both the passwords match, like if i put Joes in one of the password input boxes and Joey in the other it would return false and echo something
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh okay..

Code: Select all

&lt;?php

if(!empty($_POST))
{
  $pass1 = isset($_POST&#1111;'pass1']) ? $_POST&#1111;'pass1'] : '';
  $pass2 = isset($_POST&#1111;'pass2']) ? $_POST&#1111;'pass2'] : '';
  if( $pass1 == $pass2 )
    // match
  else
    // mismatch
}
else
{
echo &lt;&lt;&lt;STOP
&lt;input type="password" name="pass1"&gt;&lt;br /&gt;
&lt;input type="password" name="pass2"&gt;&lt;br /&gt;
STOP;
}
?&gt;
Last edited by feyd on Sun Jan 09, 2005 1:19 am, edited 1 time in total.
Post Reply