Page 1 of 1

*fixed email - problem with password

Posted: Fri Jun 11, 2004 2:03 pm
by ol4pr0
problem with email was i had 2 field names with email. so if one didnt had a value.. the error was returned dumb lol.

However i have this problem. (might be that i am stairing at it to long )

When i start up the page..
i get this error

Notice: Undefined variable: password_confirm_emtpy in on line 318
When both passwords field is blank and i do a submit i get this error
Notice: Undefined index: password_confirm in on line 49
Notice: Undefined index: password_confirm in on line 314
When only the first or the second password left blank all erros are gone

Code: Select all

//part that check if password is 0 and if password is same as the second password 

if(strlen($_POST['password'])>0)
	{
	$password = '1';
	}
	else
	{
	$password_empty ='<font style="color: '.$tcolour.'; font-size:'.$tfontsize.'px;">* Enter a password</font>';
	}
                // line 50
	if ($_POST['password'] == $_POST['password_confirm'])
	{
	$password_confirm = '1';
	}
	else
	{
	$password_confirm_emtpy ='<font style="color: '.$tcolour.'; font-size:'.$tfontsize.'px;">* you''re password must match</font>';
	}

Code: Select all

if($password_confirm == '1')
	{
                //line 314
	echo '<td class="row1"><span class="gen">Confirm password: * </span><br /><span class="gensmall"></span></td><td class="row2"><input type="password" class="post" style="width: 200px" name="password_confirm" size="25" maxlength="32" value="'.$_POST['password_confirm'].'" /></td>';
	}
	elseif($password_confirm != '1')
	{
	echo '<td class="row1"><span class="gen">Confirm password: * </span><br /><span class="gensmall"></span></td><td class="row2"><input type="password" class="post" style="width: 200px" name="password_check" size="25" maxlength="32" value="" />'.$password_confirm_emtpy.'</td>';
	}

Posted: Fri Jun 11, 2004 11:13 pm
by ol4pr0
Any help appriciated

Posted: Fri Jun 11, 2004 11:48 pm
by feyd
switch:

if ($_POST['password'] == $_POST['password_confirm'])

to

if (!empty($_POST['password']) && !empty($_POST['password_confirm']) && $_POST['password'] == $_POST['password_confirm'])

-----

your logic is kinda screwy... additionally, it's a really bad idea to write out the user's password:

Code: Select all

if($password_confirm == '1') 
   { 
                //line 314 
   echo '<td class="row1"><span class="gen">Confirm password: * </span><br /><span class="gensmall"></span></td><td class="row2"><input type="password" class="post" style="width: 200px" name="password_confirm" size="25" maxlength="32" value="'.$_POST['password_confirm'].'" /></td>'; 
   }

Posted: Sat Jun 12, 2004 12:27 pm
by ol4pr0
That still leaves me with this problem
Notice: Undefined variable: password_confirm_emtpy in on line 318
while it has been declared as far as i can see,

And if the logic is kinda screwy how would you check the second password against the first password.

Code: Select all

if (!empty($_POST['password']) && !empty($_POST['password_confirm']) && $_POST['password'] == $_POST['password_confirm']) 
	{
	$password_confirm = '1';
	}
	else
	{
	$password_confirm_emtpy ='<font style="color: '.$tcolour.'; font-size:'.$tfontsize.'px;">* you''re password must match</font>';
	} 

//line 318
echo '<td class="row1"><span class="gen">Confirm password: * </span><br /><span class="gensmall"></span></td><td class="row2"><input type="password" class="post" style="width: 200px" name="password_confirm" size="25" maxlength="32" value="" />'.$password_confirm_emtpy.'</td>'; 
   }

Posted: Sat Jun 12, 2004 12:33 pm
by ol4pr0
fixed it i guess by changing

Code: Select all

$password_confirm_empty 

//into

$password_confirm
however since the logic is kinda.. as you said i would still like to know how you would handle this. Unless that comment has something do to do with the returning the value

Posted: Sat Jun 12, 2004 1:32 pm
by feyd

Code: Select all

$error = '';
// you may want a regex to confirm syntax and correct length of the password...
if(!empty($_POST['password']) && !empty($_POST['password_confirm']) && $_POST['password'] === $_POST['password_confirm'])
{
  // yay, they match! do your insert and redirect or whatever...
}
else
{
  if(empty($_POST['password']))
  {
    $error .= (!empty($error)?'<br />':'').'&#149; must enter a password';
  }

  if(empty($_POST['password_confirm']))
  {
    $error .= (!empty($error)?'<br />':'').'&#149; must confirm password';
  }

  if(!empty($_POST['password']) && !empty($_POST['password_confirm']) && $_POST['password'] !== $_POST['password_confirm'])
  {
    $error .= (!empty($error)?'<br />':'').'&#149; passwords did not match';
  }

  die((!empty($error)?$error:'uncaught error, oops.'));
}