Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>If nama umur</title>
- </head>
- <body>
- <h1>Semak data pengguna</h1>
- <form action="" method="GET">
- Masukkan nama anda <br>
- <input type="text" name="nama"><br>
- Masukkan umur anda <br>
- <input type="number" name="umur"><br>
- <button type="submit">Semak</button>
- </form>
- <hr>
- <h1>Output</h1>
- <?php
- if(isset($_GET['nama']) && isset($_GET['umur'])){//pembuka if
- $nama=$_GET['nama'];
- $umur=$_GET['umur'];
- //nama atau umur ada data
- if($nama==null){
- echo "Masukkan nama anda<br>";
- }
- if($umur==null){
- echo "Masukkan umur anda<br>";
- }
- if($nama!=null && $umur!=null){
- echo "Terima kasih input anda<br>";
- echo "Nama anda : $nama <br>";
- echo "Nama umur : $umur <br>";
- }
- }else{
- //data borang belum isi
- echo "Sila masukkan nama & umur anda <br>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment