This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Selasa, 10 Januari 2012

LATIHAN LOGIN (web design)


Buat Database pada PHP MyAdmin, kemudian buat pada Macromedia DreamWeaver seperti dibawah ini :
 
Save dengan nama : loginAA.php

2. halA.php
<? session_start();
?>
<?php
session_start();
$user=$_SESSION['user'};
$pass=$_SESSION['pass'];
if(!empty($user)and !empty($pass))
{
echo"<table border1 align=center>";
echo"<tr><td>";
echo"<h1>Halaman kedua</h1>";
echo"<p>anda login sebagai".$_SESSION['user']."</p>";
echo"</td><td>";
echo"<p>Berikut menu navigasi anda</p>";
echo"<p><a href='halA.php'>Halaman A</a><a href='halC.php'>Halaamn C</a></p>";
echo"<a href=logout.php>logout</a></td></tr>";
}
else
{
echo "anda tidak dapat mengakses halaman ini";
}
?>

3. LoginAAA.php
<? session_start(); ?>
<?php
session_start();
$username= $_POST['username'];
$password= $_POST['password'];

if($username=='admin' AND $password=='11080978')
{
$word=md5($password);
$_SESSION['user']=$username;
$_SESSION['pass']=$word;
echo "<p> SELAMAT DATANG : &nbsp;".$username."</p>";
echo "$word";
echo "<p> MENU UTAMA </p>";
echo "<p><a href = 'halA.php'>Halaman Pertama</a>
                         <a href = 'halB.php'>Halaman Kedua</a>
                         <a href = 'halC.php'>Halaman Ketiga</a></p>";
}
else
{
echo ("Maaf username & password anda salah, silahkan login kembali di sini<a href='loginAA.php'>LOGIN</a>");
}
?>

4. Logout.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?
session_start();
session_destroy();
session_unregister("username");
session_unregister("password");
echo("<B>successfully system</B><br><br>");
echo("<a href='loginAA.php'>kehalaman utama</a>");
?>
</body>
</html>

5. Koneksi
<?
$host="localhost";
$user="root";
$pass="password";
$dbname="latihan_11080978";
$conn=mysql_connect($host,$user,$pass) or die ('Koneksi gagal..!'.mysql_error());
mysql_select_db($dbname,$conn);
?>

LATIHAN JAVA (DB_APP KARYAWAN)


Buat database Mysql, kemudian buat pada netbeans seperti gambar dibawah ini :

 
1.   Karyawan.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dbapp;

/**
 *
 * @author isca
 */
public class karyawan {

    private String nip;
    private String nama;
    private String alamat;

public karyawan(){
    }
public String getnip(){
    return nip;
    }
public void setnip(String nip){
    this.nip = nip;
    }
public String getnama(){
    return nip;
    }
public void setnama(String nama){
    this.nama = nama;
    }
public String getalamat(){
    return alamat;
    }
public void setalamat(String alamat){
    this.alamat = alamat;
    }
}

  1. KaryawanManage.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dbapp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author isca
 */
public class karyawanManage {
Connection con = null;
Statement st = null;
String url ="jdbc::mysql://localhost:3306/dbapp_11080978";
String user = "root";
String pass = "password";
/**Creates a new instance of karyawanManage*/
public karyawanManage(){
      try{
        Class.forName("com.mysql.jdbc.Driver").newInstance();
    con=DriverManager.getConnection(url, user, pass);
    st=con.createStatement();
    }
    catch(Exception ex){
ex.printStackTrace();
 }
}

public List

      getKaryawans(){
    ResultSet rs=null;
    List
    karya= new ArrayList();
    try{
        rs=st.executeQuery("SELECT NIP,NAMA,ALAMAT FROM tkaryawan");
        while(rs.next()){
            karyawan k = new karyawan();
            k.setnip(rs.getString(1));
            k.setnama(rs.getString(2));
            k.setalamat(rs.getString(3));
            karya.add(k);
        }
        }catch(Exception ex){
        ex.printStackTrace();
            }
        return karya;
    }
public int insert(karyawan k){
    int result = 0 ;
    try{
        result = st.executeUpdate("INSERT INTO tkaryawan(nip,nama,alamat)"+"VALUES("+k.getnip()+",'"+k.getnama()+"',"+k.getalamat()+"')");
    }catch(Exception ex){
        ex.printStackTrace();
    }
    return result;
    }
public int delete(karyawan k){
    int result = 0 ;
    try{
        result = st.executeUpdate("DELETE FROM tkaryawan WHERE ID = "+k.getnip()+"");
    }catch(Exception ex){
        ex.printStackTrace();
    }
    return result;
}
}