vendredi 24 septembre 2021

PHP switch always chooses last option

My PHP switch always chooses the last option. Even if I choose the the first option, my code will only execute the last option. How can I manage that it picks the option I choose?

Website:

Website

CODE:

$packages = auto_listings_get_packages();
    $pakket = array();

    foreach($packages as $package_id => $package) {
        $pakket[] = $package_id;
    }

    foreach ($pakket as $p) {

        switch ($p) {
            case '2823':
                if(isset($_POST['auto-listings-purchase'])) {
                    wp_redirect('https://website1.com');

                }
                break;
            case '2633':
                if (isset($_POST['auto-listings-purchase'])) {
                    wp_redirect('https://website2.nl');

                }
                break;
            default:
                echo 'Something went wrong. Please contact our staff.';
        }
    }

HTML

HTML




Aucun commentaire:

Enregistrer un commentaire