khirulnizam

if else nama umur

Jul 12th, 2021
1,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.21 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>If nama umur</title>
  8. </head>
  9. <body>
  10.     <h1>Semak data pengguna</h1>
  11.     <form action="" method="GET">
  12.         Masukkan nama anda <br>
  13.         <input type="text" name="nama"><br>
  14.         Masukkan umur anda <br>
  15.         <input type="number" name="umur"><br>
  16.         <button type="submit">Semak</button>
  17.     </form>
  18.     <hr>
  19.     <h1>Output</h1>
  20.     <?php
  21.    if(isset($_GET['nama']) && isset($_GET['umur'])){//pembuka if
  22.        $nama=$_GET['nama'];
  23.        $umur=$_GET['umur'];
  24.        //nama atau umur ada data
  25.        if($nama==null){
  26.            echo "Masukkan nama anda<br>";
  27.         }
  28.         if($umur==null){
  29.             echo "Masukkan umur anda<br>";
  30.         }
  31.        
  32.         if($nama!=null && $umur!=null){
  33.            echo "Terima kasih input anda<br>";
  34.             echo "Nama anda : $nama <br>";
  35.             echo "Nama umur : $umur <br>";
  36.         }
  37.     }else{
  38.         //data borang belum isi
  39.         echo "Sila masukkan nama & umur anda <br>";
  40.     }
  41.     ?>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment