This script provides validation of user editdata form inputs and updating user data in the database in case of successful validation. More...
Functions | |
terminateEditdataWithError ($errorParam) | |
validateInput ($pattern, $input) | |
Variables | |
$person_type = $_POST['person_type'] ?? '' | |
$first_name = $_POST['first_name'] ?? '' | |
$last_name = $_POST['last_name'] ?? '' | |
$company_name = $_POST['company_name'] ?? '' | |
$current_password = $_POST['current_password'] ?? '' | |
$new_password = $_POST['new_password'] ?? '' | |
$confirm_password = $_POST['confirm_password'] ?? '' | |
$patterns | |
$isFormValid = true | |
if (! $isFormValid) | |
if(isset($error) && $error==="db_access_failed") | try |
$user = $stmt->fetch(PDO::FETCH_ASSOC) | |
if(! $user) if(!password_verify($current_password, $user['password'])) | $hashed_password = password_hash($new_password, PASSWORD_BCRYPT) |
$stmt | |
This script provides validation of user editdata form inputs and updating user data in the database in case of successful validation.
Terminates and redirects back to the form page with error context parameter and all the user inputs except passwords as parameters of the redirecting GET request in case of error of data validation or database communication.
terminateEditdataWithError | ( | $errorParam | ) |
Redirects to the editdata page with the specified error parameter and current user inputs except passwords, and terminates the script.
string | $errorParam | The error parameter to be appended to the URL. |
validateInput | ( | $pattern, | |
$input ) |
Validates input based on the provided regular expression pattern.
string | $pattern | The regex pattern to validate against. |
string | $input | The input to be validated. |
$company_name = $_POST['company_name'] ?? '' |
$confirm_password = $_POST['confirm_password'] ?? '' |
$current_password = $_POST['current_password'] ?? '' |
$first_name = $_POST['first_name'] ?? '' |
if(! $user) if (!password_verify( $current_password, $user[ 'password'])) $hashed_password = password_hash($new_password, PASSWORD_BCRYPT) |
$isFormValid = true |
$last_name = $_POST['last_name'] ?? '' |
$new_password = $_POST['new_password'] ?? '' |
$patterns |
$person_type = $_POST['person_type'] ?? '' |
$stmt |
$user = $stmt->fetch(PDO::FETCH_ASSOC) |
if(! $isFormValid) | ( | ! | $isFormValid | ) |