Presentation1
- 1. <html> <head> <title>Halaman input data siswa baru</title> </head> <body> <h1>Data Siswa</h1> <FORM ACTION= "inputdata.php" METHOD="post"> Nomor induk : <BR> <INPUT TYPE= "text" NAME= "noinduknya"><BR> Nama : <BR> <INPUT TYPE= "text" NAME="namanya"><BR> Alamat : <BR> <INPUT TYPE= "text" NAME="alamatnya"><BR> <INPUT TYPE="submit" VALUE="Input"> <INPUT TYPE="reset" VALUE="Cancel"> </FORM> </BODY> </HTML>
- 2. <html> <head><title>Latihan mengambil dan menampilkan hasil query</title> </head> <body> <?php $host = 'localhost'; $user = 'root'; $pass = ''; $hasil = mysql_connect ($host, $user, $pass) or die ("koneksi gagal"); $Namadb='sekolah'; $db=mysql_select_db($Namadb); if (isset ($_POST ["noinduknya"])==TRUE && isset ($_POST ["namanya"])==TRUE && isset ($_POST ["alamatnya"])==TRUE) { $query = "INSERT INTO datasiswa (no_induk, nama_siswa, alamat_siswa) VALUES ('".$_POST["noinduknya"]."', '".$_POST["namanya"]."','".$_POST["alamatnya"]."')"; $hasil=mysql_query($query); } else { echo "<h1>penambahan data gagal</h1>"; }
- 3. $query="SELECT*FROM datasiswa"; $hasil=mysql_query($query); echo "<HR>"; while($rec=mysql_fetch_row($hasil)) { echo $rec[0]." "; echo $rec[1]." "; echo $rec[2]; echo "<BR>"; echo "<HR>"; } ?> <FORM ACTION="input.php"> <INPUT TYPE="submit" VALUE ="Ke Halaman Input"> </FORM> </BODY> </HTML>