Password Validator Using Regex (PHP)

    When building a secure web application, password validation is essential. While many tutorials teach “strong passwords,” they often overlook the importance of blocking characters that hackers commonly use in exploits like SQL injection or XSS. In this tutorial, we’ll create a PHP function that validates passwords, allows most characters, but blocks potentially dangerous ones. Why […]

    Read More

    Rounded Image Cropper using HTML5 and Javascript

      Here’s a JavaScript solution that uses HTML5’s canvas to create a basic photo upload, zoom, crop, and download functionality. This script utilizes the Cropper.js library for easy image zooming and cropping.

      Read More

      Async Data Request in PHP

        In PHP, you can send data asynchronously using curl by setting it up in a way that it doesn’t wait for a response. Here’s a function that does this by using curl with options configured to ignore the response: function sendAsyncRequest($url, $data = []){ $ch = curl_init(); // If data is provided, we assume it’s […]

        Read More

        How to use WordPress built-in Media Uploader

          To use WordPress’s default media uploader in a frontend form, you can enqueue the WordPress media scripts and use JavaScript to handle the file upload interface on the frontend. Here’s a basic example: 1. Enqueue Media Scripts In your theme’s functions.php or a custom plugin, enqueue the necessary WordPress media scripts: 2. Create a Frontend […]

          Read More

          Resize an image to fit within a specified maximum width and height in PHP

            Here is a PHP function that resizes an image to fit within a specified maximum width and height, preserving its aspect ratio. This can be useful if you’re working with WordPress or a similar PHP-based platform: Usage Explanation

            Read More

            Credit Card Number Validation in PHP

              Here’s a PHP function to validate credit card numbers using the Luhn algorithm (also known as the “modulus 10” or “mod 10” algorithm), which is commonly used to verify credit card numbers: <?php function validateCreditCard($cardNumber) { // Remove any non-digit characters (e.g., spaces, dashes) $cardNumber = preg_replace(‘/D/’, ”, $cardNumber); // Check if the card number […]

              Read More

              How to fix – Blocked script execution because the document’s frame is sandboxed and the ‘allow-scripts’ permission is set

                The error “Blocked script execution because the document’s frame is sandboxed and the ‘allow-scripts’ permission is set” indicates that the browser is preventing JavaScript execution in an <iframe> due to restrictions defined by the sandbox attribute. This attribute limits what an iframe can do for security reasons. When the sandbox attribute is applied without additional […]

                Read More

                Create individual orders for each item in WooCommerce cart

                  Add this to your theme’s functions.php file Keep only 1 product in the original order, delete other products from this order. Place the removed products (each separately) in a new order. function lpj_woocommerce_checkout_order_processed( $order_id, $posted_data, $order ) { // Get order currency $order_currency = $order->get_currency(); // Get order payment method $order_payment_gateway = $order->get_payment_method(); // Address […]

                  Read More

                  Loading...