Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Validate password if(empty(trim($_POST["password"]))){ $err = "Please enter a password."; } elseif(strlen(trim($_POST["password"])) < 6){ $err = "Password must have atleast 6 characters."; } else if(strlen(trim($_POST["new_password"])) > 96) { $login_err = "Password cannot have more than 96 characters."; }else{ $password = trim($_POST["password"]); } // Validate confirm password if(empty(trim($_POST["confirm_password"]))){ $err = "Please confirm password."; } else{ $confirm_password = trim($_POST["confirm_password"]); if(empty($err) && ($password != $confirm_password)){ $err = "Password did not match."; } } // Check input errors before inserting in database if(empty($err)){ // Prepare an insert statement $sql = "INSERT INTO users (username, password, role,notification_telegram,notification_mail) VALUES (?, ?, ?,?,?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters $tel=0; $mail=1; mysqli_stmt_bind_param($stmt, "sssii", $param_username, $param_password, $role,$tel,$mail); // Set parameters $tel=0; $mail=1; $param_username = $username; $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash $role=get_perm_string(); // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ // Redirect to login page mkdir("/var/www/html/user_files/$username"); header("LOCATION: /app/overview.php"); } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Close connection mysqli_close($link); } ?>