Silahkan Copy Kode berikut !
1. simpan dengan nama file index.php
(html>
(head>
(meta name="author" content="root">
(meta content="1;url=/fnf/index.php">
(title>frameindex(/title>
(frameset rows="20%,*" border= "1">
(frame name="atas" src= "header.php">
(frameset cols="30%,*" border= "1">
(frameset rows="30%,*" border= "1">
(frame name="kiriatas" src="pengguna.php">
(frame name="kiribawah" src="menu.php">
(/frameset>
(frame name="kananatas" src="tambahmahasiswa.php">
(/frameset>
(/frameset>
(/head>
(body bgcolor=blue>
(/body>
(/html>
2. simpan dengan nama file header.php
(html>
(head>
(meta name="author" content="root">
(meta content="1;url=/fnf/index.php">
(/head>
(body bgcolor=blue>
(center>
(h1>SELAMAT DATANG(/h1>
(/center>
(/body>
(/html>
3. simpan dengan nama file pengguna.php
(html>
(head>
(meta name="author" content="root">
(meta content="1;url=/fnf/index.php">
(/head>
(body bgcolor=blue>
(?php
include("koneksi.php");
$nama=($_POST["user"]);
$katasandi=($_POST["password"]);
function simpan()
{
$entrylogin = "INSERT INTO login " .
"(pengguna, sandi)" .
"VALUES ('$nama', $katasandi)";
}
?>
(form action="tamu.php" method="post" target = "kananatas">
Username : (input name="user" type="text" /> (br> (br>
Password : (input name="password" type="password" /> (br> (br>
(input type = "submit" value="Masuk" onClick = simpan() > (br>
(/form>
(/body>
(/html>
3. simpan dengan nama file menu.php
(html>
(head>(title>Menu(/title>(/head>
(body>
(?php
echo '(font face="verdana" size="2">';
class submenu {
var $urls;
var $desps;
var $cot;
var $id;
var $buka_menuSymbol = '(+)';
var $tutup_menudSymbol = '(--)';
var $itemBranch = ' |---';
function buat($identitas)
{
$this -> cot = 0;
$this -> id = $identitas;
}
function tambah($alamat_url, $desp)
{
$this -> urls[$this -> cot] = $alamat_url;
$this -> desps[$this -> cot] = $desp;
$this -> cot++;
}
function buka_menu()
{
$i = 0;
while($i ($this -> cot)
{
if ($i == 0)
{
global $PHP_SELF;
echo '(b>(a href="'.$PHP_SELF.'?kejadian = tutup_menu&id=">'.$this->tutup_menudSymbol.$this->desps[0].'(/a>(/b>(br>';
}
else {
echo $this->itemBranch.'(a href="'.$this->urls[$i].'" target ="kananatas">'.$this->desps[$i].'(/a>(br>';
}
$i++;
}
}
function tutup_menu() {
global $PHP_SELF;
if (! $this->id){
} else {
echo '(b>(a href="'.$PHP_SELF.'?kejadian=buka_menu&id='.$this->id.'">'.$this->buka_menuSymbol.$this->desps[0].' (/a>(/b>(br>';
}
}
}
class menu {
var $submenus;
var $cot;
var $id;
function buat() {
$this->cot=0;
$this->id=2;
}
function tambah($submenu) {
$this->submenus[$this->cot]=new submenu;
$this->submenus[$this->cot]=$submenu;
$this->cot++;
}
function tampilkan() {
$i=0;
$tmp = new submenu;
while ($i($this->cot) {
$tmp=$this->submenus[$i];
if ($tmp->id==(string)$this->id) {
$tmp->buka_menu();
}
else {
$tmp->tutup_menu();
}
$i++;
}
}
function hide() {
$tmp = new submenu;
$tmp->tutup_menu();
}
}
$sm_1 = new submenu;
$sm_1->buat('1');
$sm_1->tambah('',' Download File');
$sm_1->tambah('http://vb92kharisma.blogspot.com','Blog');
$sm_1->tambah('modul.php','modul');
$sm_2=new submenu;
$sm_2->buat('2');
$sm_2->tambah('',' Search Engine');
$sm_2->tambah('http://www.google.com','Google');
$sm_2->tambah('http://www.yahoo.com','Yahoo');
$sm_2->tambah('http://www.Altavista.com','Altavista');
$sm_2->tambah('http://www.searchindonesia.com','Search Indonesia');
$sm_3=new submenu;
$sm_3->buat('3');
$sm_3->tambah('',' Berita');
$sm_3->tambah('http://www.detik.com','Detik');
$sm_3->tambah('http://www.detikinet.com','Detikinet');
$sm_3->tambah('http://www.kompas.com','Kompas');
$sm_3->tambah('http://www.Astaga.com','Astaga');
$sm_4= new submenu;
$sm_4->buat('3');
$sm_4->tambah('',' Entri Data');
$sm_4->tambah('tambahmahasiswa.php','Mahasiswa');
$sm_4->tambah('','Nilai');
$m_1 = new menu;
$m_1->buat();
$m_1->tambah($sm_1);
$m_1->tambah($sm_2);
$m_1->tambah($sm_3);
$m_1->tambah($sm_4);
if ($kejadian=='') {
$m_1->tampilkan();
}
if ($kejadian=='buka_menu') {
$m_1->id=$id;
$m_1->tampilkan();
}
if ($kejadian=='tutup_menu') {
$m_1->id=$id;
$m_1->hide();
$m_1->tampilkan();
}
echo '(/font>';
?>
(/body>
(/html>
4. Simpan dengan Nama FIle tambahmahasiswa.php
(HTML>
(head>
(TITLE>Menambah Data Mahasiswa(/TITLE>
(meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
(script language="JavaScript">
(!--
function trim(str)
{
return str.replace(/^\s+|\s+$/g,'');
}
function checkForm()
{
var cnpm, cnama, cprodi, cjenjang, calamat;
with(window.document.msgform)
{
cnpm = textnpm;
cnama = textnama;
cprodi = comboprodi;
cjenjang = combojenjang;
calamat = textalamat;
}
if(trim(cnpm.value) == '')
{
alert('Silakan isi dulu NPM, jangan sampai kosong ');
cnpm.focus();
return false;
}
else if (trims(cnpm.value).length != 14)
{
alert('Silakan isi dengan Benar, perlu diingat...panjang karakter harus = 14 !! ');
cnpm.focus();
return false;
}
else if(trim(cnama.value) == '')
{
alert('Jangan lupa, SEtiap mahasiswa pasti punya nama');
cnama.focus();
return false;
}
else if(trim(calamat.value) == '')
{
alert('Tulis dulu Alamat Mahasiswa dengan lengkap');
calamat.focus();
return false;
}
else
{
cnpm.value = trim(cnpm.value);
cnama.value = trim(cnama.value);
cprodi.value = trim(cprodi.value);
cjenjang.value = trim(cjenjang.value);
calamat.value = trim(calamat.value);
return true;
}
}
//-->(/script>
(/head>
(BODY>
(CENTER>
(H1>Menambah Data Mahasiswa(/H1>
(HR>
(FORM ACTION = "simpanmahasiswa.php" onsubmit="return checkForm();" METHOD = "POST" name="msgform" ENCTYPE="MULTIPART/FORM-DATA">
(TABLE>
(pre>
(TR>(TD align ="right">(font size="2">NPM :(/font>(/TD>(TD>(INPUT id = "textnpm" NAME = "textnpm" TYPE = "TEXT" onKeypress = "focusnama()"MAXLENGTH = "14" SIZE = "15">(/TD>(/TR>
(TR>(TD align ="right">(font size="2">Nama :(/font(/TD>(TD>(INPUT id = "textnama" NAME = "textnama" TYPE = "TEXT" MAXLENGTH = "30" SIZE = "32">(/TD>(/TR>
(TR>(TD align ="right">(font size="2">Prodi :(/font(/TD>(TD>(SELECT id = "comboprodi" NAME = "comboprodi">
(OPTION VALUE = "TI" SELECTED >Teknik Informatika (/OPTION>
(OPTION VALUE = "SI" >Sistem Informasi(/OPTION>
(OPTION VALUE = "MI" >Manajemen Informatika(/OPTION>
(OPTION VALUE = "TK" >Teknik Komputer(/OPTION>
(OPTION VALUE = "KA" >KOmputerisasi Akuntansi(/OPTION>
(TR>(TD align ="right">(font size="2">Jenjang :(/font(/TD>(TD>(SELECT id = "combojenjang" NAME = "combojenjang">
(OPTION VALUE = "1" SELECTED>D1(/OPTION>
(OPTION VALUE = "2" >D2(/OPTION>
(OPTION VALUE = "3" >D3(/OPTION>
(OPTION VALUE = "4" >S1(/OPTION>
(OPTION VALUE = "5" >S2(/OPTION>
(OPTION VALUE = "5" >S3 (/OPTION>
(TR>(TD align ="right">(font size="2">ALamat :(/TD>(TD>(TEXTAREA id = "textalamat" NAME = "textalamat" ROWS = "4" COLS = "40">(/TEXTAREA>(/TD>(/TR>
(/pre>
(/TABLE>
(HR>
(INPUT NAME = "tombolSimpan" TYPE = "Submit" VALUE = "Simpan" >
(/CENTER>
(/BODY>
(/HTML>
5. simpanmahasiswa.php
(?php
include ("koneksi.php");
mysql_select_db("akademik", $koneksi);
$sql= " INSERT INTO mahasiswa (npm, nama, prodi, jenjang, alamat)
VALUES ('$_POST[textnpm]','$_POST[textnama]','$_POST[comboprodi]','$_POST[combojenjang]','$_POST[textalamat]')";
if (!mysql_query($sql,$koneksi))
{
die('Error: ' . mysql_error());
}
echo "1 sudah ditambahkan....";
mysql_close($koneksi);
echo '(form action= "lihatmahasiswa.php" method="post">';
echo '(input type = "submit" value = "lihat mahasiswa" name="cmdlihat">';
echo '(/form>'
?>
6. FIle koneksi.php
(?php
$namaserver="localhost";
$username="root";
$password="";
$koneksi = mysql_connect($namaserver,$username,$password);
if (!$koneksi)
{
die('Titak dapat melakukan Koneksi: ' . mysql_error());
}
?>
Sabtu, 08 November 2008
Modul PHP
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar