Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Other functions  /  CheckPassword

CheckPassword
CheckPassword (
string $field1
string $field2
boolean $setEditMsg = true 
)

Arguments:

Name Description
$field1 The name of the first passfield.
$field2 The name of the second passfield
$setEditMsg Should a message beeing displayed in an edit form that when leaving the fields blank the current passwords will be kept?

Description:

With this function you can compare the values of two password fields. This function is build because its a common check made with to password fields (check if they are the same).

When the form is a insert form, the password fields are both required and need to be the same. When the form is an edit form, the password fields can be left empty by the visitor and the original passfield will be kept.

Example

<?php

// include the class
include("FH3/class.FormHandler.php");

// create a new formhandler object
$form = new FormHandler("myForm");

// create 2 passfields
$form->PassField("Password""password"FH_PASSWORD);
$form->PassField("Confirm password""re_password");

// check if both values are the same
// if not, the form will automatically load the form again
// with a error message
$form->checkPassword("password""re_password");

// set the commit after form function
$form->onCorrect("doRun");

// flush it...
$form->flush();

// display the password
function doRun($data
{
    echo 
"Your chosen password: "$data['password'];
}

?>

See also: PassField

Latest change: 05 March 10 / 08:57

Comments

Marien 01 December 08 / 14:15  
If you are not using the database functionality you miss the edit mode. If you want to go to edit mode to disable the requirement of the fields just add:

$form->edit = 1;

Now are the two fields only required when you fill them.

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license