Assalamualaikum wr.wb. Welcome To My Blog Copyright @rhandiki.com

Web Programing Dasar Lanjutan 1

Tugas Web Programing Dasar Lanjutan 1 :

1. Source Code Koneksi :

<?php
$koneksi=mysql_connect("localhost","root","12345678") or die("Gagal koneksi Server".mysql_error());
if($koneksi){echo "Koneksi Berhasil";
}
?>

2. Source Code Masukan Form/ID :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>From Masukan</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="masukkansim.php"
target="_self">
<table width="342" border="1">
<tr>
<td colspan="3"><strong>Masukan Data Anggota</strong> </td>
</tr>
<tr>
<td width="95">ID Anggota </td>
<td width="3">:</td>
<td width="222"><input name="txtid" type="text" id="txtid" size="10"
maxlength="6" /></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="txtnama" type="text" id="txtnama" size="35"
maxlength="35" /></td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><input name="txtalamat" type="text" id="txtalamat" size="35"
maxlength="60" /></td>
</tr>
<tr>
<td>Kelamin</td>
<td>:</td>
<td><label>
<input name="rbgender" type="radio" value="p"/>
Pria
<input name="rbgender" type="radio" value="w"/>
Wanita</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="Simpan" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

3. Source Code Masukan sim/Simpan :

<html">
<body>
<?php
$koneksi=mysql_connect("localhost","root","12345678") or die ("Gagal koneksi server".mysql_error());
if($koneksi){
mysql_select_db("buku_11100457",$koneksi) or die ("Database gagal dibuka".mysql_error());
$txtid=$_POST['txtid'];
$txtnama=$_POST['txtnama'];
$txtalamat=$_POST['txtalamat'];
$rbgender=$_POST['rbgender'];
$sql="INSERT INTO anggota(id,nama,alamat,kelamin)
VALUES('$txtid','$txtnama','$txtalamat','$rbgender')";
mysql_query($sql,$koneksi) or die ("Gagal query disimpan".mysql_error());
echo"Data Berhasil disimpan";
}
?>
</body>
</html>