function f_recover($mode, $f_mailid)
{
    $mode = sanitize($mode);
    $f_mailid = sanitize($f_mailid);
    $f_data = f_data(f_id_from_email($f_mailid), 'f_id', 'f_fname', 'f_uname');
    if ($mode == 'f_uname') {
        recovery_user_pass($f_mailid, 'Recovery: Your username', "Hello " . $f_data['f_fname'] . ",\n\nYour username is: " . $f_data['f_uname'] . "\n\n-Swift Airlines");
    } else {
        if ($mode == 'f_password') {
            $generated_password = substr(md5(rand(999, 999999)), 0, 8);
            f_change_password($f_data['f_id'], $generated_password);
            update_f($f_data['f_id'], array('f_passrec' => '1'));
            recovery_user_pass($f_mailid, 'Recovery: Your password', "Hello " . $f_data['f_fname'] . ",\n\nYour new password is: " . $generated_password . "\n\n-TOFSIS");
        }
    }
}
        if (!preg_match('/^[a-z]{2,30}$/i', $_POST['f_lname'])) {
            $errors[] = 'Your last name can contain only alphabets';
        }
    }
}
?>

	<h3>Settings</h3>

<?php 
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
    echo 'Updated!';
} else {
    if (empty($_POST) === false && empty($errors) === true) {
        $update_data = array('f_fname' => $_POST['f_fname'], 'f_lname' => $_POST['f_lname'], 'f_mailid' => $_POST['f_mailid']);
        update_f($session_f_id, $update_data);
        header('Location: settings.php?success');
        exit;
    } else {
        if (empty($errors) === false) {
            echo output_errors($errors);
        }
    }
    ?>

<form action="" method="POST">
	<br/>
	First Name: <br/>
	<input type="text" name="f_fname" value="<?php 
    echo $f_data['f_fname'];
    ?>