MODUL 8 ( Pengenalan Internet )
Pada MODUL 8 KKPI ini saya akan menjelaskan cara membuat 5 link pada html dan berikut cara dan langkah - langkahnya :
1) Pertama kita buat terlebiha dahulu tampilan awal atau indexnya dan berikut scrip dan gambar dari menu
Pertama atau index :
a) Scrip
<?php
echo "
<head><body background=\"LG0.jpg\"><br><br><br><br><br><br><title>SELAMAT DATANG JASA PENJUALAN LAPTOP</title></br></br></br></br></br></br>
<h2 align=center><font color=\"blue\">SELAMAT DATANG DI PERUSAHAAN JASA PENJUALAN LAPTOP</font></h2>
<center>
<tr><td></td>
<td><a href=\"table.php\"><input type=submit name=\"Daftar Karyawan\" value=\"Dafta Karyawan\"></a>
<td><a href=\"pencarian.php\"><input type=submit name=\"Pencarian Data Karyawan\" value=\"Pencarian Data Karyawan\"></a>
<td><a href=\"index2.php\"><input type=submit name=\"Daftar\" value=\"Daftar Jadi Karyawan\"></a>
<td><a href=\"backup.php\"><input type=submit name=\"Backup\" value=\"Backup\"></a>
<td><a href=\"recovery_data.php\"><input type=submit name=\"Restore\" value=\"Restore\"></a>
</td></td></tr>
</center>
</table>
</body>";
?>
b) Gambar tampilan
Tampilannya :
a) Scrip
<?php
$user = "root";
$password = "123456";
$komputer = "localhost";
$data = "edvito";
$sambung = mysql_connect($komputer,$user,$password);
$pilah = mysql_select_db($data);
$cari = "SELECT *FROM `daftar` WHERE 'nama' like '%'" ;
$a=mysql_query($cari);
echo "<html>
<body background=\"LG1.jpg\">
<table align=center border=1 cellpadding='5' cellspacing='8' >
<tr bgcolor='silver'>
<h3 align=center>Table Daftar Karyawan</h3>
<td align=\"center\">Nama</td>
<td align=\"center\">Umur</td>
<td align=\"center\">Codekaryawan</td>
<td align=\"center\">Userid</td>
<td align=\"center\">Password</td>
<td align=\"center\">Aksi</td>
<td align=\"center\">Jabatan</td>
</tr>";
$while= mysql_query ("SELECT * FROM `daftar` ORDER BY nama");
$no=1;
while($data = mysql_fetch_array ($while)) {
echo "<tr>
<td align=\"center\">$data[0]</td>
<td align=\"center\">$data[1]</td>
<td align=\"center\">$data[2]</td>
<td align=\"center\">$data[3]</td>
<td align=\"center\">$data[4]</td>
<th><a href=edit.php?nama=$data[nama] class=a><input type=submit value='Edit' align=center></a>
<a href=\"delete.php?nama=$data[nama]\" class=a onClick=\"return confirm('Anda Yakin Menghapus Akun >>$data[nama]<< Ini.')\"><input type=submit value='Hapus' align=center></a></tH>
<td align=\"center\">$data[5]</td>
</tr>";
}
echo "</table>";
echo "<p align=\"center\"><a href=\"index.php\"><input type=\"button\" value='kembali' align=center></a>";
echo "<a href=\"index2.php\"><input type=\"button\" value='Daftar Baru' align=center></a>";
echo "<a href=\"pencarian.php\"><input type=\"button\" value='Pencarian Data' align=center></a></p></td></h2>";
echo "
</body>
</html>";
?>
b) Gambar tampilan
3. Ketiga cara membuat tampilan link menu kedua yaitu pencarian daftar karyawan berikut scrip dan gambar
Tampilannya :a) Scrip
<html>
<head>
<title>Pencarian</title>
</head>
<body background="LG4">
<form name="formcari" method="post" action="hasil-pencarian.php">
<table width="330" border="0" align="center" cellpadding="0">
<td height="25" colspan="3">
<p align="center"><strong>>>Pencarian Data Karyawan<<</p></strong>
</td>
</tr>
<tr><td> Cari Data </td>
<td> : <select name='jabatan'>
<option selected>--Pilih JABATAN--</option>
<option>Direktur</option>
<option>Sekretaris</option>
<option>Bendahara</option>
<option>HRD</option
<option>Karyawan</option>
<option>OB</option>
</select>
</td></tr>
</tr>
<td></td>
<td>
<a href="table.php"><input type="button" value='Lihat Table' align=center></a>
<input type="SUBMIT" name="SUBMIT" id="SUBMIT" value="search"></td>
</table>
<p align="center"><a href="index.php"><input type="button" value='Kembali'></p></a>
</body>
</form>
</html>
b) Gambar tampilan
4. Keempat cara membuat tampilan link menu ketiga yaitu daftar jadi karyawan berikut scrip dan gambar
Tampilannya :
a) Scrip
<?php
echo "<html>
<head><title>Daftar Jadi Pegawai penjual Laptop</title></head>
<body background=\"LG0.jpg\" width=\"120\" height=\"30\">
<form action=\"sambung.php\" class=\"js-signin signin\" method=\"post\">
<h3 align=center>Selamat Dtaang</h3>
<h5 align=center>Cari Pengalaman Dan Keterampilan Disini, Selamat Bekerja.</h5>
<table align=center border=0 cellpadding=20>
<tr><td><font color=\"Red\">Nama </font></td><td> : <input name=\"nama\" type=\"text\" size=\"29\" Required=\"required\" placeholder=\"Masukkan Nama\"/></td></tr>
<tr><td><font color=\"Red\">Umur </font></td><td> : <input name=\"umur\" type=\"number\" size=\"29\" Required=\"required\" placeholder=\"Masukkan Umur\"/></td></tr>
<tr><td><font color=\"Red\">Code Karyawan </font></td><td> : <input name=\"codekaryawan\" type=\"password\" size=\"29\" Required=\"required\" placeholder=\"Code Karyawan\"/></td>
<tr><td><font color=\"Red\">User ID </font></td><td> : <input name=\"userid\" type=\"text\" size=\"29\" Required=\"required\" placeholder=\"User ID\"/></td>
<tr><td><font color=\"Red\">Password </font></td><td> : <input name=\"password\" type=\"password\" size=\"29\" Required=\"required\"/ placeholder=\"Password\"></td>
<tr><td><font color=\"Red\">Jabatan </td><td> : <select name='jabatan'>
<option selected>--Pilih JABATAN--</option>
<option>Direktur</option>
<option>Sekretaris</option>
<option>Bendahara</option>
<option>HRD</option
<option>Karyawan</option>
<option>OB</option>
</select>
</td></tr>
</div><tr>
<td colspan=\"2\" align=\"center\"><input name=\"Submit\" type=\"submit\" value=\"Daftar\">
<a href=\"index.php\"><input type=\"button\" value='Kembali' align=\"center\"></a>
</div>
</td>
</tr>
</form>
</table>
</body>
<div align=\"center\"></div>
</html>";
?>
b) Gambar tampilan
5. Kelima cara membuat tampilan link menu keempat yaitu backup berikut scrip dan gambar
Tampilannya :
a) Scrip
<head>
<title>Backup Database - Perusahaan Jasa Penjualan LAPTOP</title>
</head>
<body background=LG2>
<form action="" method="post" name="postform"><br><br><br><br><br><br><br><br><br><br>
<p align="center"><font color="blue"><em>Aplikasi ini digunakan untuk <strong><a href="backup.php">backup</a></strong> dan <strong><a href="recovery_data.php">restore</a></strong> semua data yang ada didalam database "<strong>Edvito</strong>".</font></em></p>
<div align="center">
<p><font color=blue>Backup semua data yang ada didalam Database Pendaftaran Karyawan</color></p>
<p>
<input type="submit" name="backup" onClick="return confirm('Apakah Anda Yakin Akan Membackup?')"value="Proses Backup" />
</p>
<a href="index.php"><img src='LG.jpg' height=50 width=50></a>
</div>
</form>
</p>
<?php
if(isset($_POST['backup'])){
$file=date("DdMY").'_backup_data_'.time().'.sql';
backup_tables("localhost","root","123456","edvito",$file);
?>
<p align="center"> </p>
<h3 align=center><font color="black">Backup database telah selesai.</font></h3>
<p align="center"><a style="cursor:pointer" onclick="location.href='downloadbackup.php?nama_file=<?php echo $file;?>'" title="Download"><font color="black"><img src='Download.png' height=70 width=70></font></a>
</p>
<?php
}else{
unset($_POST['backup']);
}
function backup_tables($host,$user,$pass,$name,$nama_file,$tables = '*')
{
$user="root";
$pass="123456";
$kom="localhost";
$data="edvito";
$sambung= mysql_connect ( $kom,$user,$pass );
$pilih= mysql_select_db( $data );
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}else{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
$nama_file;
$handle = fopen('./backup/'.$nama_file,'w+');
fwrite($handle,$return);
fclose($handle);
}
?>
</body>
</html>
b) Gambar tampilan
Berikut scrip dan gambar tampilannya :
a) Scrip
<html>
<head>
<title>Data Restore</title>
</head>
<body background='LG3.jpg'>
<br><br><br><br><br><br><br><br><br><br>
<form enctype="multipart/form-data" action="recovery_data.php" method="post">
<p align="center"><font color="blue"><em>Aplikasi ini digunakan untuk <strong><a href="backup.php">backup</a></strong> dan <strong><a href="recovery_data.php">restore</a></strong> semua data yang ada didalam database "<strong>Edvito</strong>".</font></em></p>
<table align="center">
<tr><td>File Backup Database (*.sql) <input type="file" name="datafile" size="30" id="gambar" /></td></tr>
<div align="center">
<tr><td><input type="submit" onclick="return confirm('Apakah Anda yakin akan restore database?')" name="restore" value="Restore Database" /></td>
<tr><td><a href="index.php"><input type=button value=Kembali></a>
</div>
</tr>
</table>
</form>
<?php
if(isset($_POST['restore'])){
$koneksi=mysql_connect("localhost","root","123456");
mysql_select_db("edvito",$koneksi);
$nama_file=$_FILES['datafile']['name'];
$ukuran=$_FILES['datafile']['size'];
//periksa jika data yang dimasukan belum lengkap
if ($nama_file=="")
{
echo "Fatal Jaringan Error";
}else{
//definisikan variabel file dan alamat file
$uploaddir='./restore/';
$alamatfile=$uploaddir.$nama_file;
//periksa jika proses upload berjalan sukses
if (move_uploaded_file($_FILES['datafile']['tmp_name'],$alamatfile))
{
$filename = './restore/'.$nama_file.'';
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line)
{
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
{
// Perform the query
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo "<center>Berhasil Restore Database, silahkan di cek...</center>";
echo "<h2><center><a href='table.php'>Lihat Tabel Daftar</a></center></h2>";
}else{
//jika gagal
echo "Proses upload gagal, kode error = " . $_FILES['location']['error'];
}
}
}else{
unset($_POST['restore']);
}
?>
</body>
</head>
b) Gambar tampilan
7. Selesai dan semoga bermanfaat :D
0 komentar:
Posting Komentar