Gan, Tentang POPUP di PHP

gan saya kan mau bikin tugas, jadi saya mau munculin popup jika bil2 kurang dari 30% dari bil1,
saya sudah coba2 tapii gagal :'(  bisa minta tolong, saya pakai php & html & css
<!DOCTYPE html>
<html>
<head>
    <title>Simulasi Kredit | UD.Abadi Motor Semarang</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <?php 
    if(isset($_POST['hitung'])){
        $bil1 = $_POST['bil1'];
        $bil2 = $_POST['bil2'];
        $operasi = $_POST['operasi'];
        switch ($operasi) {
            case '12bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.03;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/12;
            break;
            case '24bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.06;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/24;
            break;
            case '36bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.09;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/36;
            break;
        
            #case 'minimal':
            #   $bil_lanjut = $bil1*30/100;
            #break;         
        }
    }
    #else($bil2 < $bil_lanjut) {
    #   echo"<script>alert('DP anda Kurang dari 30%');history.go(-1);</script>";
    #}
    ?>
    <div class="kalkulator">
        <h2 class="judul">SIMULASI KREDIT</h2>
        <form method="post" action="index.php">         
            <input type="text" name="bil1" class="bil" autocomplete="off" placeholder="Harga OTR">
            <input type="text" name="bil2" class="bil" autocomplete="off" placeholder="DP - Minimal 30%">
            <select class="opt" name="operasi" placeholder="Tenor">
                <option value="12bulan">12 Bulan</option>
                <option value="24bulan">24 Bulan</option>
                <option value="36bulan">36 Bulan</option>
                
            </select>
            <input type="submit" name="hitung" value="Hitung" class="tombol">                                           
        </form>
        <?php if(isset($_POST['hitung'])){ ?>
            <input type="text" value="<?php echo $hasil3; ?>" class="bil" placeholder="Hasil" disable>
        <?php }else{ ?>
            <input type="text" value="0" class="bil">
        <?php } ?>          
    </div>
</body>
</html>
avatar ariyano

@ariyano

2 Kontribusi 0 Poin

  • bisa sertakan script yang sudah kamu buat ? ? aku bisa aja ngasih full dari awal script nya,,, tapi nanti jadinya ga bantu tugas tapi buatin tugas 😅 - @mitsuky06
  • Baca aturan main di forum ini ya, sertakan kode atau gambar jika perlu - @ahanafi


Jawaban

mungkin kaya gini ya?

 <?php 
    $bil1 = $_POST['bil1'];
    $bil2 = $_POST['bil2'];
    $bil_lanjut = $bil1*30/100;

    if(isset($_POST['hitung'])){
        $operasi = $_POST['operasi'];
        switch ($operasi) {
            case '12bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.03;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/12;
            break;
            case '24bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.06;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/24;
            break;
            case '36bulan':
                $hasil = $bil1-$bil2;
                $hasil1 = $hasil*0.09;
                $hasil2 = $hasil1+$hasil;
                $hasil3 = $hasil2/36;
            break;       
        }
    }

    if($bil2 < $bil_lanjut) {
        echo '<script type="text/javascript">alert("DP anda Kurang dari 30%");history.go(-1);</script>';
    } ?>

avatar IbnuHamzah404

@IbnuHamzah404

2 Kontribusi 0 Poin



My dream residence could be very one of a kind from the usual house. i would love to introduce it to you if you are interested in it. 
the shape of my dream residence like a strawberry; the roof if inexperienced, and walls are crimson. 
let’s enter my dream house and look around: it consists of a dwelling-room, a observe-room, a bed room, and a bathroom. the wall of the bedroom is covered with mink, so that i'm able to sleep with a candy dream and sense extra at ease. there are lots of factors in my house ----which includes computers,televisions, telephones, tables, beds, and so on. of path, the cost of my dream residence may be very huge, too. 
how can make my dream come real? we can understand it most effective by our hard operatingn。
bing image search
avatar businessmenugui1

@businessmenugui1

1 Kontribusi 0 Poin


Login untuk gabung berdiskusi
premium logo tube

Hey, sedang ada diskon premium untuk akses semua kelas. Lihat di sini