| [ask] numpang nanya nih mastah,
<html> <head> <title> Pendaftaran </title> </head> <body> <p><center><font size="60px"> Pengisian Data Siswa </font></p>
<form action="" method="post" >
<br><center>Nama:</br> <br> <center><input type="text" name="name" /></br> <br> <center>Kelas:</br> <br><center><input type="text" name="kelas" /></br> <br> <center>No.abs:</br> <br><input type="text" name="no" /></br> <br> <center>Hobi:</br> <br><input type="text" name="hobi" /></br> <br> <center>Tanggal Lahir</br> <br><center><select name="tgl"> <option selected="selected" > -Tanggal- </option> <?php for($a=1; $a<=31; $a+=1){ echo"<option value=$a> $a </option>"; } ?> </select> <select name="bln"> <option selected="selected">-Bulan-</option> <?php $bulan=array("Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"); $jlh_bln=count($bulan); for($c=0; $c<$jlh_bln; $c+=1){ echo"<option value=$bulan[$c]> $bulan[$c] </option>"; } ?> </select> <select name="thn"> <option selected="selected">-Tahun-</option> <?php $i = $_POST['thn']; $umur = $_POST['umur']; for($i=2020; $i>=1990; $i-=1){ echo"<option value=$i> $i </option>"; } $umur = date("Y") - $i ; ?> </select></br> <br><center><input type="submit" value="Kirim" /></br> </form> <br> <table border='1' width="600" align="center"> <tr> <td><center>Nama</td> <td ><center>Kelas</td> <td ><center>No.abs</td> <td ><center>Hobi</td> <td ><center>Tanggal Lahir</td> <td><center>Umur</td> </tr> <tr> <td> <?php echo $_POST["name"]; ?> </td> <td> <?php echo $_POST["kelas"]; ?> </td> <td> <?php echo $_POST["no"]; ?> </td> <td> <?php echo $_POST["hobi"]; ?> </td> <td> <?php echo $_POST["tgl"]; ?>
<?php echo $_POST["bln"]; ?>
<?php echo $_POST["thn"]; ?> </td> <td> <?php echo ($umur); ?> </td> </tr> </br> </table> <?php $name = $_POST['name']; $kelas = $_POST['kelas']; $no = $_POST['no']; $hobi = $_POST['hobi'];
if ($name == "" || $kelas =="" || $no =="" || $hobi =="") { echo "<br> Mohon isi data yang masih kosong </br>";}
?> </body> </html>
--> di bagian $umur, umur kok masih gak bener ya ? trus biar tabel baru keluar stelah di klik submit gimana ya ? help nya ya ..., :) |
| sekedar saran: [1] jika masih bingung, pecahkan antara form inputan dan bagian prosesnya [2] lihat lagi logiknya: //.. $i = $_POST['thn']; $umur = $_POST['umur']; for($i=2020; $i>=1990; $i-=1){ echo"<option value=$i> $i </option>"; } $umur = date("Y") - $i ; //.. terakhir nilai $i=1990, sehingga dari pernyataan: $umur = date("Y") - $i; selalu bernilai: $umur = date("Y") - 1990;
[3] bawah ane jagonya, ane gak bisa koding cuman asal koming ^_^V |
Tidak ada komentar:
Posting Komentar