newhck / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

Error always appears #198

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
include("PFBC/Form.php");

$error = false;

$form = new Form("validation");

$form->addElement(new Element_Hidden("action", "update_user"));
$form->addElement(new Element_Password(__('Password'), "password", array(
            "required" => 1

            )));
$form->addElement(new Element_Password(__("Confirm Password"), 
"confirmpassword", array(
            "required" => 1

            )));
$form->addElement(new Element_Email(__("Email"), "email", array(
            "required" => 1,
            "value" => $userinfo['email']

            )));
$form->addElement(new Element_Password(__('Old Pasword'), "oldpass", array(
            "required" => 1

            )));
$form->addElement(new Element_Button);
$form->addElement(new Element_Button("Cancel", "button", array(
            "onclick" => "history.go(-1);"
            )));
// echo resultBlock($errors, $successes);
if (Form::isValid("validation")) { 
    // print_r($_POST);
    $error = false;
    if ($_POST["password"] != $_POST["confirmpassword"]) {
        Form::setError("validation", __("Error: Confirm password does not match with new password"));
        $error = true;
    }
    $entered_pass = generateHash($_POST['oldpass'], $loggedInUser->hash_pw);
    if ($entered_pass != $loggedInUser->hash_pw) {
        Form::setError("validation", __("Error: Wrong old password"));
        $error = true;
    }
    if ($error == false) {
        Form::clearValues("validation");
        $stmt = $mysqli->prepare("UPDATE " . $db_table_prefix . "users
        SET
        email = ?,
        password = ?
        WHERE
        id = ?");
        $newpass = generateHash($_POST['password']);
        $stmt->bind_param("ssi", $_POST['email'], $newpass, $id);
        $result = $stmt->execute();
        $stmt->close();
        $successes[] = __("Updated settings");
    }

}

Whenever I load the form, the errors always appear, any idea why? 

Original issue reported on code.google.com by animestr...@gmail.com on 8 Apr 2013 at 11:24

GoogleCodeExporter commented 8 years ago
I have the exact same issue. Did you find a solution to this?

Original comment by hamishro...@gmail.com on 21 Jun 2013 at 1:17

GoogleCodeExporter commented 8 years ago
Yep.. was mostly stupidity on my end

if (!empty($_POST)) {
  //PFBC Code goes here
}

Original comment by animestr...@gmail.com on 21 Jun 2013 at 12:44