$password = generateRandomString('5'); echo $password; //Hash the password provided $hash = encryptPassword($password); //Save new password for user //If already exists, then update password and if not insert record $params = array(); $response = null; $params = add_where('idPerson', $id, $params); $response = select_from_table('password', 'idPerson', $params); //echo $response; if (empty(json_decode($response, true))) { //Insert $record = array(); $records = array(); $record = add_field('idPerson', $id, $record); $record = add_field('password', $hash, $record); $record = add_field('misses', "0", $record); $record = add_field('locked', "0", $record); array_push($records, $record); insert_into_table('password', $records); } else { //Modify $update = array(); $where = array(); $update = add_field("password", $hash, $update); $update = add_field("misses", "0", $update); $update = add_field("locked", "0", $update); $where = add_where("idPerson", $id, $where); modify_record('password', $update, $where); }
<?php require_once '..\\utilities\\functions.php'; header('Access-Control-Allow-Origin: *'); // Define Table $table = 'person'; //Build Fields and Values to insert $update = array(); $where = array(); //Fields with new values $update = add_field("address1", "1220 Topeka Ice Cream Lane", $update); //Table selection for the record(s) to be updated $where = add_where("nameLast", "Lee", $where); //echo json_encode($update). "<br>"; modify_record($table, $update, $where);