Bizniz online’s

Just another WordPress.com weblog

Archive for February, 2008

PHP Programming & My SQL Fundamental

Posted by biznizonline on February 28, 2008

PHP Programming
Fundamental
dan
MySQL
Fundamental

Penulis dapat dihubungi melalui email endy@artivisi.com

I. Pengantar
A. Konsep Multi Tier Application
Aplikasi internet berbasis web, yang akan kita kembangkan dalam
pelatihan ini, adalah salah satu penerapan multi tier application.
Multi tier application adalah aplikasi yang dibagi menjadi beberapa
bagian yang menjalankan fungsi masing-masing. Secara umum, ada tiga
bagian utama dari multi tier application:
Client side presentation
Server side business logic
Backend storage
Client Side Presentation
Client side presentation mengatur bagaimana aplikasi berinteraksi
dengan user. Yang dimaksud dengan interaksi antara lain adalah:
bagaimana data ditampilkan, bagaimana fungsi dan fitur aplikasi
ditampilkan.
Dalam aplikasi berbasis web, client side presentation dibuat dengan
bahasa HTML, CSS, dan JavaScript. Beberapa tool yang digunakan untuk
membuat client side presentation diantaranya Microsoft Frontpage,
Macromedia Dreamweaver, dan sebagainya.
Client side presentation berbasis web contohnya adalah tampilan aplikasi
email yang kita buka dengan browser.
Server Side Business Logic
Server side business logic, sering disebut juga middle tier, adalah bagian
yang bertanggung jawab atas cara kerja aplikasi. Di dalamnya kita
mengatur bagaimana fungsi dan fitur aplikasi dapat bekerja dengan baik.
Dalam aplikasi berbasis web, ada beberapa alternatif yang dapat
digunakan, ditentukan oleh jenis platiform yang digunakan. Alternatif ini
akan dijelaskan lebih detail pada bagian selanjutnya.
3
Back End Storage
Bagian ini mengatur cara penyimpanan data. Penyimpanan data
merupakan materi yang cukup kompleks dalam pembangunan aplikasi.
Karena kecepatan, keutuhan, dan keamanan data merupakan faktor kritis
dalam aplikasi.
Ada banyak solusi database yang tersedia di pasaran. Pada umumnya,
database yang digunakan bertipe relasional (Relational Database
Management System – RDBMS). Manajemen data dilakukan dengan
bahasa SQL (Standard Query Language).
B. Perbedaan Web Based Programming dengan System
Programming
Pembuatan aplikasi berbasis web berbeda dengan pembuatan aplikasi
berbasis windows (visual programming), misalnya Visual Basic, Delphi,
atau KDevelop. Dalam visual programming, kita meningkatkan kecepatan
dan kinerja aplikasi dengan mengoptimasi penggunaan memori,
manajemen proses, dan pengaturan Input-Output. Pada pemrograman
berbasis web, faktor yang menentukan kinerja aplikasi adalah kecepatan
akses database dan kecepatan akses jaringan dan internet.
Perbedaan kedua, adalah cara aplikasi berjalan. Pada aplikasi visual,
aplikasi dibangun dengan menggunakan tool tertentu, kemudian
dikompilasi. Hasilnya dapat langsung digunakan dalam komputer. Aplikasi
berbasis web tidak dapat dijalankan langsung di komputer. Untuk
menjalankannya, dibutuhkan engine tertentu, dalam hal ini web server.
C. Teknologi Alternatif
Teknologi server side yang akan kita pelajari pada modul ini adalah PHP.
Walaupun demikian, perlu diketahui teknologi alternatif yang dapat
menjadi bahan pertimbangan.
CGI Script
CGI Script dapat dibuat dengan berbagai bahasa pemrograman, misalnya
Perl atau Phyton. Teknologi ini pernah sangat populer di masa awal
berkembangnya web based application. Tetapi saat ini banyak
4
ditinggalkan orang karena tidak efisien, tidak fleksibel, dan keamanannya
rendah.
Proprietary API
Teknologi ini adalah bahasa pemrograman yang disediakan masingmasing
webserver, misalnya ISAPI atau NSAPI. Teknologi ini memiliki
kelemahan, yaitu hanya dapat berjalan di webserver tertentu, sehingga
mengurangi portabilitas.
ASP
Merupakan solusi server side programming dari Microsoft. Teknologi ini
banyak digunakan oleh para programmer yang berlatar belakang Visual
Basic. Database pasangannya adalah MS SQL Server. Operating system
pasangannya adalah Window 2000 Server yang menjalankan webserver
Microsoft IIS.
JavaServlet/JSP
Teknologi server side Java. Mempunyai banyak keunggulan dan
kemudahan pemrograman. Tetapi karena murni berorientasi objek,
banyak programmer pemula kesulitan menggunakannya. Selain itu, Java
juga adalah bahasa pemrograman yang relatif rumit bagi pemula.
Keunggulannya, sangat portabel. Dapat dipindahkan dengan mudah dari
Windows ke Unix dan sebaliknya.
ColdFusion
Bahasa pemrograman ini mirip dengan HTML, menggunakan tag untuk
membentuk blok-blok programnya.
PHP
Banyak digunakan oleh programmer berlatar belakang C/C++ karena
kemiripan syntaxnya. Open source, karenanya gratis dan bebas.
Database pasangannya biasanya MySQL, dijalankan bersama webserver
Apache di atas operating system Linux. Semuanya gratis dan bebas.
5
II. Hello World
Dalam bagian ini, kita akan membuat kode program sederhana untuk
menunjukkan bagaimana aplikasi PHP bekerja.
Kita membutuhkan satu file yang akan kita namakan welcome.php
A. Source code
File welcome.php akan berisi tiga baris kode sebagai berikut :
<?
echo(“Hallo user .. !”));
?>
B. Compile
Kode program pada umumnya akan mengalami proses kompilasi
setelah source code selesai dibuat. Tetapi karena PHP adalah interpreted
language, kita tidak perlu mengkompile kode ini.
C. Deploy
Untuk mendeploy, copy file welcome.php ke dalam folder percobaan
yang telah disiapkan pada bagian instalasi di atas.
D. Error message
Kode di atas akan mengalami error, karena kita terlalu banyak menulis
tanda ). Pesan error akan muncul di layar, menunjukkan lokasi error
pada kode, dan tipe errornya.
E. Output
Perbaiki kode welcome.php sehingga menjadi seperti berikut ini:
<?
echo(“Hallo user .. !”));
?>
kode akan dapat dijalankan dengan baik dan menghasilkan output
sebagai berikut :
6
7
III. Statement dan Comment
A. Statement
Statement adalah satuan perintah dalam PHP. Statement harus diakhiri
dengan tanda semicolon/titik-koma (;).
Contoh statement :
echo(“hello user … !”);
Contoh lainnya :
echo(“4 + 5 = ” . 4+5);
B. Expression
Expression adalah satu bagian kecil kode yang akan dihitung hasilnya
oleh php. Contoh expression :
4 + 5
Penggunaan expression :
echo(“4 + 5 = ” . 4+5);
C. Comment
Comment adalah bagian dari kode yang tidak dieksekusi/dijalankan.
Comment dibuat untuk memperjelas atau memberi keterangan pada
kode program.
Ada dua cara menulis comment : comment satu baris dan comment
banyak baris.
Comment satu baris dibuat dengan menggunakan tanda //. Semua
statement yang ada di kanan // tidak dijalankan oleh interpreter. Contoh
penggunaan:
echo(“4 + 5 = ” . 4+5); // menampilkan hasil 4 + 5
Comment banyak baris dibuat dengan menggunakan pasangan /* dan
*/. Semua tulisan yang dibuat di antara tanda tersebut tidak akan
dieksekusi oleh interpreter. Contoh penggunaan :
8
/*
kode ini akan menampilkan hasil dari
4 + 5
*/
echo(“4 + 5 = ” . 4+5);
9
IV. Variabel dan Tipe Data
Variabel digunakan sebagai tempat penyimpanan data sementara. Data yang
disimpan dalam variabel akan hilang setelah program selesai dieksekusi.
Untuk penyimpanan data yang permanen, kita dapat menyimpan data di
database atau di disk. Silahkan mengacu pada Akses Database untuk
mendalami penggunaan database, dan Akses File dan Folder untuk
penyimpanan data di filesystem.
Variabel di PHP diawali dengan tanda $.
Untuk dapat menggunakan variabel, ada dua langkah yang harus dilakukan,
deklarasi dan inisialisasi.
A. Deklarasi variabel
Deklarasi variabel bisa disebut juga memperkenalkan atau
mendaftarkan variabel ke dalam program.
Dalam php, deklarasi variabel seringkali digabung dengan inisialisasi.
Variabel dalam PHP dinyatakan dengan awalan $.
Contoh :
$namaPembeli
$jumlahBarang
$harga
Ada beberapa aturan yang diikuti berkenaan dengan penggunaan nama
variabel. Aturan pemberian nama variabel :
Dimulai dengan tanda $
Karakter pertama harus huruf atau garis bawah ( _ )
Karakter berikutnya boleh huruf, angka, atau garis bawah.
B. Inisialisasi variabel
Inisialisasi variabel adalah mengisi nilai untuk pertama kalinya ke dalam
variabel. Contoh inisialisasi :
10
$namaDepan = “Endy”;
$namaBelakang = “Muhardin”;
$jumlahBarang = 3;
$harga = 1000;
C. Tipe data
Dalam bahasa pemrograman yang lain, ada bermacam-macam tipe
data, misalnya integer(bilangan bulat), float(bilangan pecahan),
char(karakter angka dan huruf), string(kumpulan huruf atau kata), dan
berbagai tipe lainnya.
PHP mengenal dua tipe data sederhana; numerik dan literal. Ditambah
dengan dua tipe data yang tidak sederhana, yaitu array dan object.
Tipe Numerik dapat menyimpan bilangan bulat. PHP mampu
menyimpan data bilangan bulat dengan jangkauan dari -2 milyar sampai
+2 milyar. Contoh bilangan bulat: 3, 7, 20.
Selain itu, tipe numerik juga digunakan untuk menyimpan bilangan
pecahan
Tipe literal digunakan untuk menyimpan data berupa kumpulan huruf,
kata, dan angka.
Tipe boolean, yang dikenal dalam bahasa program yang lainnya, tidak
ada dalam PHP. Untuk menguji benar salah (true false), kita
menggunakan tipe data yang tersedia. FALSE dapat digantikan oleh
integer 0, double 0.0 atau string kosong, yaitu “”. Selain nilai itu, semua
dianggap TRUE.
Variabel dapat digunakan untuk menyimpan berbagai jenis data.
Misalnya data numerik yang dapat dioperasikan secara matematika.
Contoh :
$jumlahBarang = 3;
$harga = 1000;
$pembayaran = $jumlahBarang * $harga;
pada contoh di atas, variabel pembayaran akan menyimpan nilai 3000.
Sedangkan data non numerik (disebut juga data literal) tidak dapat
dioperasikan secara matematika. Contoh :
$nama = $namaDepan + $namaBelakang;
11
variabel nama akan menyimpan gabungan dari dua variabel, yaitu
“Endy Muhardin”.
Secara umum, data literal ditandai dengan pasangan “ dan “. Data
numerik tidak dikelilingi oleh “ dan “. Tetapi biasanya PHP akan secara
otomatis mengubah tipe data sesuai kebutuhan. Contoh :
$jalan = “Gubeng Kertajaya”;
$noRumah = 29;
$blok = 4c;
$jumlahPenghuni = 3;
$alamat = $jalan + $noRumah;
$hasil = $noRumah + $jumlahPenghuni;
$hasilAneh = $blok + $noRumah;
Pada sampel kode di atas, variabel alamat akan menyimpan nilai
Gubeng Kertajaya 29. PHP secara otomatis mengubah tipe data
variabel noRumah (numerik) menjadi literal. Variabel alamat akan bertipe
literal.
Variabel hasil akan menyimpan nilai 32, yaitu penjumlahan dari 29 dan
3.
Perhatikan, konversi otomatis ini kadang berjalan secara tidak
semestinya. Ini dapat dilihat dari variabel hasilAneh yang akan
menyimpan nilai 7. PHP mengambil nilai numerik dari variabel blok, yaitu
4, kemudian menambahkannya dengan isi variabel jumlahPenghuni. Hasil
akhirnya adalah 4 + 3, yaitu 7.
D. Passing Variable
Variabel dapat di-passing atau diteruskan ke halaman web berikutnya
yang diakses user. Ada beberapa teknik untuk meneruskan variabel,
diantaranya :
Melalui URL
Melalui Form
Melalui Cookie
URL
Variabel diteruskan melalui URL dengan format sbb
12
[alamat web]?var1=nilai1&var2=nilai2
Misalnya, untuk memberikan variabel $nama berisi “Endy” dan $alamat =
“Surabaya” ke welcome.php, kita akan menulis :
welcome.php?nama=Endy&alamat=Surabaya
Di kolom address pada explorer. Untuk lebih jelasnya, perhatikan gambar
berikut.
Variabel ini dapat diakses di script welcome.php dengan cara sebagai
berikut :
<?
echo(“Variabel $user berisi : $user”);
echo(“Variabel $alamat berisi : $alamat”);
?>
Form
Cara lain untuk mengirim kedua variabel tersebut adalah dengan
menggunakan form dengan kode sebagai berikut :
<html>
<head>
<title>Passing Variable</title>
</head>
<body>
<form method=”POST” action=”welcome.php”>
<p>Nama : <input type=”text” name=”nama”></p>
<p>Alamat : <input type=”text” name=”alamat”></p>
<p><input type=”submit” value=”Submit” name=”B1″></p>
</form>
</body>
</html>
13
dan tampilan sebagai berikut :
form tersebut akan diproses oleh file welcome.php
Cookie
Penggunaan cookie akan dibahas pada bagian tentang session.
14
V. Operators
Operator digunakan untuk memanipulasi nilai suatu variabel. Variabel yang
nilainya dimodifikasi oleh operator disebut operand. Contoh penggunaan
operator misalnya 13 – 3. 13 dan 3 adalah operand. Tanda “-” disebut
operator.
Untuk kemudahan penjelasan, operator diklasifikasikan menjadi :
Arithmetic Operator
Assignment Operator
Comparison Operator
Logical Operator
Lain-lain
A. Arithmetic operator
Arithmetic Operator digunakan untuk melakukan perhitungan
matematika. Misalnya
$a = 5 + 3;
Operator “+” berfungsi untuk menambahkan kedua operand (5 dan 3).
Ada beberapa arithmetic operator, yaitu :
+ : penjumlahan
- : pengurangan
* : perkalian
/ : pembagian
% : nilai sisa pembagian
Contoh penggunaan :
Buatlah dua file berikut :
operator.htm
15
Komponen Nama Variabel
TextField kiri operand1
TextField kanan operand2
Operator op
Action hasilArithmetic.php
operator.php
<?
$perhitungan = $operand1.$operator.$operand2;
eval(“$hasil = $perhitungan;”);
echo(“Hasil Perhitungan : “);
echo(“<b>”);
echo($hasil);
echo(“</b>”);
?>
B. Relational operator
Relational operator digunakan untuk membandingkan nilai dari dua
operand. Hasil perbandingan dinyatakan dalam nilai boolean. TRUE
berarti benar, dan FALSE berarti salah.
Beberapa jenis relational operator :
== : memeriksa apakah operand kanan bernilai sama dengan
operand kiri
> : memeriksa apakah operand kiri bernilai lebih besar daripada
operand kanan
16
< : memeriksa apakah operand kiri bernilai lebih kecil dengan
operand kanan
>= : memeriksa apakah operand kiri bernilai lebih besar atau
sama dengan operand kanan
<= : memeriksa apakah operand kiri bernilai lebih kecil atau
sama dengan operand kanan
!= : memeriksa apakah operand kanan tidak bernilai sama
dengan operand kiri
Untuk mengetahui cara penggunaan relational operator, buatlah contoh
seperti petunjuk berikut.
Tambahkan operator.htm sehingga menjadi seperti gambar di bawah:
Komponen Nama Variabel
TextField kiri operand1
TextField kanan operand2
Operator Op
Action hasilRelational.php
Buat file operator.php seperti ini :
17
<?
$perhitungan = $operand1.$op.$operand2;
$hasil = eval($perhitungan);
echo(“Hasil Perhitungan : “);
echo(“<b>”);
echo($hasil);
echo(“</b>”);
?>
C. Logical operator
Logical Operator digunakan untuk membandingkan dua nilai variabel
yang bertipe boolean. Hasil yang didapat dari penggunaan logical
operator adalah boolean.
Tabel logika berikut digunakan sebagai pedoman perhitungan
Operand kiri Operator Nama Operand kanan Hasil
TRUE && And TRUE TRUE
TRUE && And FALSE FALSE
FALSE && And TRUE FALSE
FALSE && And FALSE FALSE
TRUE || Or TRUE TRUE
TRUE || Or FALSE TRUE
FALSE || Or TRUE TRUE
FALSE || Or FALSE FALSE
TRUE Xor Exclusive Or TRUE FALSE
TRUE Xor Exclusive Or FALSE TRUE
FALSE Xor Exclusive Or TRUE TRUE
FALSE Xor Exclusive Or FALSE FALSE
! Not TRUE FALSE
! Not FALSE TRUE
Untuk melihat pemakaian logical operator, ikuti petunjuk di bawah ini.
File operator.php masih sama seperti di atas.
File operator.htm menjadi seperti di bawah ini :
18
D. Assignment Operator
Assignment operator digunakan untuk memberi/mengisi nilai ke dalam
variabel tertentu. Contoh sederhana :
$nama = “endy”;
Pada contoh di atas, operator “=” digunakan untuk mengisi nilai “endy”
ke dalam variabel nama.
Selain operator “=”, ada beberapa assignment operator yang lainnya,
seperti dapat dilihat pada penjelasan berikut :
Operator +=
Penjelasan :
Menambahkan nilai pada variabel
Contoh :
$a += 3;
sama dengan
$a = $a + 3;
Operator -=
Penjelasan :
Mengurangi nilai pada variabel
Contoh :
19
$a -= 3;
sama dengan
$a = $a – 3;
Operator *=
Penjelasan :
Mengalikan variabel dengan bilangan tertentu
Contoh :
$a *= 3;
sama dengan
$a = $a * 3;
Operator /=
Penjelasan :
Membagi variabel dengan bilangan tertentu
Contoh :
$a /= 3;
sama dengan
$a = $a / 3;
Operator %=
Penjelasan :
Mencari sisa hasil bagi variabel dengan bilangan tertentu
Contoh :
$a %= 3;
sama dengan
$a = $a % 3;
Operator &=
Penjelasan :
Melakukan operasi logical AND pada variabel
Contoh :
$a &= TRUE;
sama dengan
$a = $a & TRUE;
20
Operator |=
Penjelasan :
Melakukan operasi logical OR pada variabel
Contoh :
$a |= FALSE;
sama dengan
$a = $a | FALSE;
Operator ^=
Penjelasan :
Melakukan operasi bitwise xor pada variabel
Contoh :
$a ^= 3;
sama dengan
$a = $a ^ 3;
Operator .=
Penjelasan :
Menambahkan String pada variabel
Contoh :
$a .= “rudi”;
sama dengan
$a = $a . “rudi”;
Operator ++
Penjelasan :
Menambahkan nilai satu pada variabel
Contoh :
$a ++ ;
sama dengan
$a = $a + 1;
Operator –
Penjelasan :
Mengurangi nilai satu pada variabel
Contoh :
21
$a — ;
sama dengan
$a = $a – 1;
E. Operator lain-lain
Operator penggabung String
Pada PHP, string digabungkan dengan operator . (titik).
Contoh penggunaan :
$string1 = “Hello”;
$string2 = “World”;
echo($string1.” “.$string2);
akan menampilkan :
Hello World
Operator percabangan
Percabangan pada umumnya dilakukan dengan struktur if-else, seperti
pada contoh berikut:
if($user == “endy”){
echo(“Welcome Endy”);
}else{
echo(“Wrong username”);
}
Hal yang sama dapat dilakukan dengan cara :
echo($user == endy ? “Welcome Endy” : “Wrong username”);
Perhatikan tanda ? dan :
PHP memeriksa apakah pernyataan di sebelah kiri “?” benar atau salah.
Apabila benar, pernyataan di sebelah kiri tanda “:” dieksekusi. Bila salah,
pernyataan di sebelah kanan “:” dieksekusi.
Lebih jelas tentang percabangan dapat dipelajari dalam bagian Control
Flow.
Operator Error Suppression
PHP menampilkan pesan error apabila built-in function (function yang
disediakan PHP) mengalami error. Misalnya tidak bisa membuka file,
tidak bisa mengakses database, dan lainnya.
Pada saat pembuatan aplikasi, pesan error ini sangat membantu dalam
menyelesaikan dan memperbaiki kesalahan pemrograman. Tetapi, pada
saat aplikasi selesai dibuat dan digunakan secara umum, pesan error ini
akan mengganggu pengguna.
Untuk mematikan pesan error tersebut, kita menggunakan operator @.
22
Contoh penggunaan :
@chdir(“temp”);
Pada kondisi normal, function chdir akan menimbulkan pesan error
apabila direktori temp tidak ditemukan atau tidak dapat diakses. Dengan
menggunakan operator @, PHP akan “diam saja” apabila direktori temp
tidak ditemukan atau tidak dapat diakses.
23
VI. Control Flow
Control flow dalam bahasa Indonesia dapat diartikan sebagai aliran
kendali. Maksud sebenarnya dari control flow adalah bagaimana urutan
eksekusi perintah di dalam program.
Misalnya, dalam function :
function testFlow()
{
int a = 5;
echo(a);
}
Perintah pertama yang dijalankan adalah mengisi nilai 5 ke dalam
variabel a.
Perintah kedua yang dijalankan adalah menampilkan nilai yang
tersimpan dalam variabel a (dalam hal ini 5) ke browser.
Control flow di atas merupakan sebuah contoh sederhana. Beberapa
control flow yang tersedia dalam PHP :
Percabangan (branching)
Perulangan (looping)
Perpindahan (jumping)
A. Percabangan
Percabangan, atau sering disebut juga dengan istilah decision-making,
memungkinkan aplikasi untuk memeriksa isi suatu variabel atau hasil
perhitungan ekspresi dan mengambil tindakan yang sesuai. Ada dua jenis
percabangan, dipilih berdasarkan kriteria pemeriksaan dan jumlah pilihan
yang tersedia.
if – else
Konstruksi if-else dapat dijelaskan sebagai berikut :
24
if(condition)
{
// statement 1 goes here
}
else
{
// statemant 2 goes here
}
// statement 3 goes here
Aliran program :
1. Condition akan diperiksa
2. Bila bernilai true, statement 1 akan dijalankan
3. Bila bernilai false, statement 2 akan dijalankan
4. Statement 3 dijalankan
if – elseif – else
Untuk pilihan yang lebih dari dua, PHP menyediakan konstruksi if-elseifelse.
if(condition1)
{
// statement 1
}
elseif(condition2)
{
// statement 2
}
else
{
// statement 3
}
// statement 4
Aliran program :
Ada 3 kemungkinan aliran program :
Apabila condition 1 bernilai true :
1. Statement 1 dijalankan
2. Statement 4 dijalankan
Apabila condition 1 bernilai false, dan condition 2 bernilai true :
1. Statement 2 dijalankan
2. Statement 4 dijalankan
25
Apabila condition 1 dan condition 2 bernilai false :
1. Statement 3 dijalankan
2. Statement 4 dijalankan
Contoh penggunaan if-else dapat dilihat dengan mengikuti contoh di
bawah. Buatlah dua file, control_flow.htm dan ifDemo.php.
control_flow.htm mempunyai tampilan sebagai berikut :
ifDemo.php berisi listing kode sebagai berikut :
26
<?
// ifDemo.php
// digunakan bersama control_flow.htm
$kelabu = “#303030″;
$putih = “#FFFFFF”;
if($kelamin1 == “Pria”){
$latar1 = $kelabu;
}else{
$latar1 = $putih;
}
if($kelamin2 == “Pria”){
$latar2 = $kelabu;
}else{
$latar2 = $putih;
}
if($kelamin3 == “Pria”){
$latar3 = $kelabu;
}else{
$latar3 = $putih;
}
if($kelamin4 == “Pria”){
$latar4 = $kelabu;
}else{
$latar4 = $putih;
}
$output = “
<table border=1>
<tr>
<td background=$latar1>$nama1</td>
</tr>
<tr>
<td background=$latar2>$nama2</td>
</tr>
<tr>
<td background=$latar3>$nama3</td>
</tr>
<tr>
<td background=$latar4>$nama4</td>
</tr>
</table>
“;
echo($output);
?>
switch – case
konstruksi switch dapat dijelaskan sebagai berikut :
27
switch(a){
case 1;
// statement 1 goes here
break;
case 2;
// statement 2 goes here
break;
case 3;
// statement 3 goes here
break;
default;
// statement 4 goes here
break;
}
// statement 5 goes here
Aliran program :
1. Variabel a diperiksa
2. Statement dieksekusi
a) Apabila a == 1, statement 1 dijalankan
b) Apabila a == 2, statement 2 dijalankan
c) Apabila a == 3, statement 3 dijalankan
d) Apabila a tidak memenuhi 2a – 2c, statement 4 dijalankan
3. Statement 5 dijalankan
Keyword break memegang peranan penting di sini. Fungsinya adalah
mencegah fall-through, bandingkan dengan program berikut(break di
baris ke 5 dihilangkan)
switch(a){
case 1;
// statement 1 goes here
case 2;
// statement 2 goes here
break;
case 3;
// statement 3 goes here
break;
default;
// statement 4 goes here
break;
}
Aliran program :
1. variabel a diperiksa
2a. Apabila a == 1, statement 1 dijalankan, kemudian
menjalankan statement 2.
2b. Apabila a == 2, statement 2 dijalankan
28
2c. Apabila a == 3, statement 3 dijalankan
2d. Apabila a tidak memenuhi 2a – 2c, statement 4 dijalankan
3. Statement 5 dijalankan
Perbedaan ada pada langkah 2a. Bandingkan dengan listing pertama.
Untuk melihat contoh penggunaan switch – case, tambahkan tampilan
pada control_flow.htm menjadi seperti gambar di bawah.
Buat file switchDemo.php sebagai berikut :
<?
switch($bulan){
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
$hari = 31;
break;
case 4 :
case 6 :
case 8 :
case 11 :
$hari = 30;
break;
case 2 :
if(($tahun%4) == 0){
$hari = 29;
}else{
$hari = 28;
}
}
echo(“<h2>Jumlah hari pada bulan $bulan tahun $tahun =
$hari hari</h2>”);
?>
B. Perulangan
for
Looping dengan for disebut juga determinate loop, artinya looping yang
jumlah pengulangannya (iterasi) telah ditentukan di awal looping.
29
Ada beberapa bagian penting dari for loop:
Initialization expression
Stop condition
Iterative expression
Loop body
Initialization Expression dijalankan satu kali, pada saat looping dimulai.
Biasanya bagian ini digunakan untuk menginisialisasi
counter(penghitung).
Stop condition diperiksa nilainya sebelum setiap iterasi dieksekusi.
Apabila condition bernilai false, iterasi dihentikan.
Iterative expression dilakukan setelah iterasi dieksekusi. Bagian ini
biasanya digunakan untuk menambah nilai counter.
Loop body dieksekusi sekali setiap iterasi, merupakan perintah yang ingin
kita lakukan berulang-ulang.
Contoh kode di atas akan menampilkan tulisan Hello World di browser
sebanyak 10 kali.
Untuk melihat contoh penggunaan for, tambahkan tampilan pada
control_flow.htm menjadi seperti gambar di bawah.
Pasang baris kode berikut pada forDemo.php
<?
$jumlah = 0;
for($i=0; $i<strlen($kata); $i++){
if(substr($kata, $i, 1) == $huruf){
$jumlah ++;
}
}
?>
while
while loop juga dikenal dengan istilah indeterminate loop, artinya jumlah
loopingnya tidak ditentukan pada awal looping. while loop lebih
sederhana daripada for loop, karena cuma memiliki dua bagian:
30
Stop Condition
Loop body
Stop condition diperiksa sebelum tiap iterasi dilaksanakan. Selama stop
condition bernilai true, perintah dalam loop body akan dilakukan
berulang-ulang. Iterasi akan dihentikan apabila stop condition bernilai
false.
Sama seperti pada for loop, loop body dilaksanakan satu kali setiap
iterasi.
Loop di atas akan berjalan terus tanpa henti, karena tidak ada perintah
yang mengubah nilai stop condition.
do-while loop merupakan modifikasi dari while loop. Bentuknya dapat
dilihat pada sampel kode berikut:
do{
// some statement
}
while (a == true)
untuk melihat contoh penggunaan while, gunakan form yang sama
dengan forDemo.
Tambahkan baris kode berikut pada whileDemo.php
<?
$jumlah = 0;
$i = 0;
while($i<strlen($kata)){
if(substr($kata, $i, 1) == $huruf){
$jumlah ++;
$i++;
}
}
?>
C. Perpindahan
break
Break digunakan dalam looping untuk menghentikan suatu loop. Untuk
lebih jelasnya, perhatikan kode berikut :
31
<?
// melakukan break pada $i == 2
for($i = 0; $1<5; $i++){
if($i == 2){
break;
}
echo(“Nilai i : $i <br>”);
}
echo(“Loop Selesai”);
?>
kode tersebut akan melakukan break pada saat i bernilai 2, sehingga
akan menghasilkan output sebagai berikut :
Nilai i : 0
Nilai i : 1
Loop Selesai
continue
continue berfungsi untuk melewati satu iterasi/putaran dalam rangkaian
loop. Untuk lebih jelasnya, kode di atas akan kita modifikasi.
<?
// melakukan continue pada $i == 2
for($i = 0; $1<5; $i++){
if($i == 2){
continue;
}
echo(“Nilai i : $i <br>”);
}
echo(“Loop Selesai”);
?>
kode tersebut akan melakukan break pada saat i bernilai 2, sehingga
akan menghasilkan output sebagai berikut :
Nilai i : 0
Nilai i : 1
Nilai i : 3
Nilai i : 4
Loop Selesai
return
perintah return berfungsi untuk memerintahkan kode untuk keluar dari
fungsi. Fungsi akan kita pelajari dengan lebih mendalam pada bagian
selanjutnya. Untuk sementara, fungsi cuma akan digunakan untuk
menjelaskan return. Perhatikan kode di bawah :
32
<?
function testReturn(){
for($i = 0; $1<5; $i++){
// melakukan return pada $i == 2
if($i == 2){
return;
}
echo(“Nilai i : $i <br>”);
}
echo(“Loop Selesai”);
}
// jalankan function
testReturn();
echo(“Function selesai”);
?>
outputnya adalah :
Nilai i : 0
Nilai i : 0
Function Selesai
Perhatikan bahwa Loop Selesai tidak dijalankan. Ini menunjukkan
bahwa setelah return dieksekusi, program langsung keluar dari function
dan mengeksekusi perintah setelah function, yaitu
echo(“Function Selesai”);
exit
exit digunakan untuk menghentikan keseluruhan script php. Untuk lebih
jelasnya, kita akan modifikasi kode di atas menjadi seperti berikut :
<?
function testExit(){
for($i = 0; $1<5; $i++){
// melakukan return pada $i == 2
if($i == 2){
exit;
}
echo(“Nilai i : $i <br>”);
}
echo(“Loop Selesai”);
}
// jalankan function
testExit();
echo(“Function selesai”);
?>
outputnya adalah :
Nilai i : 0
Nilai i : 0
Function Selesai
33
Perhatikan bahwa baris
echo(“Function selesai”);
Tidak dijalankan.
Untuk melihat contoh penggunaan break, continue, return, dan exit;
tambahkan tampilan pada control_flow.htm menjadi seperti gambar di
bawah.
Tambahkan baris kode berikut pada perpindahan.php
<?
/*
variabel yang dibutuhkan
$mark -> tempat dilakukan perpindahan
$perintah -> perintah pindah : continue, break, return, exit
*/
function execute($tanda, $perintah){
for($i=0; $i<11; $i++){
if($i == $tanda){
if($perintah == “continue”){
continue;
}elseif($perintah == “break”){
break;
}
elseif($perintah == “return”){
return;
}elseif($perintah == “exit”){
exit;
}
}
echo($i.”<br>”);
}
echo(“Looping Selesai<br>”);
}
execute($tanda, $perintah);
echo(“Function execute selesai<br>”);
?>
34
VII. Array
A. Konsep array
Array adalah kumpulan beberapa data yang disimpan dalam satu
variabel. Jadi, berbeda dengan variabel sebelumnya yang hanya
menyimpan satu nilai saja, array dapat menampung lebih dari satu nilai.
Sebagai contoh, kita akan menyimpan data teman-teman kita dalam
satu variabel $teman. Ada tiga orang teman yang akan kita masukkan ke
dalam variabel tersebut. Secara visual, dapat digambarkan sebagai
berikut :
Charlie Ani Budi
$teman
Tiap nilai dalam array (disebut elemen) diakses dengan menggunakan
index. PHP mengenal dua macam index, yaitu index numerik dan index
asosiatif. Index numerik menggunakan angka untuk menandai tiap
elemen, sedangkan index asosiatif memberi nama untuk masing-masing
elemen. Penggunaan index akan dibahas lebih detail di bawah.
B. Inisialisasi array
Inisialisasi (mengisi nilai) array $teman di atas dilakukan dengan cara
sebagai berikut :
$teman = array(“Charlie”, “Ani”, “Budi”);
Kode di atas akan menjadikan $teman array berindex numerik. Selain
dengan cara di atas, kita juga dapat membuat array yang sama dengan
cara :
$teman[] = “Charlie”;
$teman[] = “Ani”;
$teman[] = “Charlie”;
hasilnya adalah array berindeks numerik yang dapat digambarkan
sebagai berikut :
Charlie Ani Budi
0 1 2
$teman
35
untuk membuat array berindex asosiatif, kita membutuhkan label atau
nama untuk masing-masing elemen. Contoh di atas akan dikembangkan
agar dapat menyimpan nomer telepon masing-masing teman. Gambaran
visualnya adalah sebagai berikut :
Charlie Ani Budi
123 528 456
$rekan
pada gambar di atas, nama masing-masing teman akan dijadikan label
untuk nilai nomer telepon yang disimpan. Kode programnya adalah
sebagai berikut :
$rekan = array (“Charlie”=>123, “Ani”=>528, “Budi”=>456);
atau
$rekan = array(“Charlie”=>123);
$rekan [“Ani”] = 528;
$rekan [“Budi”] = 456;
C. Navigasi array
Navigasi (mengakses nilai) array dapat dilakukan dengan looping.
Misalnya untuk menampilkan isi array berindex numerik di atas, kita akan
menggunakan kode seperti berikut :
for($i=0; $i<length($teman);$i++){
echo(“Array $teman index ke [$i] adalah $teman[$i]”);
echo(“<br>”);
}
Untuk mengakses array berindex asosiatif, kita tidak dapat
menggunakan loop seperti di atas, karena label/index elemen disimpan
dalam bentuk string.
Loop untuk mengakses array berindex asosiatif dapat dilihat pada
sampel kode di bawah :
while(list($index, $nilai) = each($rekan)){
echo(“Array $rekan index $index berisi nilai $nilai”);
echo(“<br>”);
}
ada dua fungsi yang terlibat di atas, each dan list. Fungsi each
berguna untuk mengakses masing-masing elemen dalam array. Elemen
yang dihasilkan adalah pasangan key dan value, dimana key adalah
36
indexnya dan value adalah isinya. Pasangan tersebut akan dipisahkan
oleh fungsi list dan dimasukkan ke dalam variabel $index dan $nilai.
D. Fungsi-fungsi array
sort
Elemen-elemen dalam array dapat diurutkan dengan menggunakan
fungsi sort(). Contoh penggunaannya adalah sebagai berikut :
sort($teman);
for($i=0; $i<length($teman);$i++){
echo(“Array $teman index ke [$i] adalah $teman[$i]”);
echo(“<br>”);
}
akan menghasilkan output :
Array teman index ke 0 adalah Ani
Array teman index ke 1 adalah Budi
Array teman index ke 2 adalah Charlie
asort dan ksort
Asort digunakan untuk mengurutkan asosiatif array menurut isinya.
Contoh penggunaan :
asort($rekan);
while(list($index, $nilai) = each($rekan)){
echo(“Array $rekan index $index berisi nilai $nilai”);
echo(“<br>”);
}
akan menghasilkan output :
Array $rekan index Charlie berisi nilai 123
Array $rekan index Budi berisi nilai 456
Array $rekan index Ani berisi nilai 528
ksort digunakan untuk mengurutkan asosiatif array menurut indexnya.
Contoh penggunaan :
ksort($rekan);
while(list($index, $nilai) = each($rekan)){
echo(“Array $rekan index $index berisi nilai $nilai”);
echo(“<br>”);
}
akan menghasilkan output :
Array $rekan index Ani berisi nilai 528
Array $rekan index Budi berisi nilai 456
Array $rekan index Charlie berisi nilai 123
37
VIII. Function
A. Konsep function
Function adalah kumpulan beberapa statement yang dibuat dengan
tujuan menyelesaikan satu tugas tertentu.
B. Return value dan parameter
Perhatikan kode berikut :
function add($a, $b){
return $a + $b;
}
Function sederhana di atas akan menerima masukan berupa dua angka.
Kemudian kedua angka tersebut akan dijumlahkan, dan hasilnya
dikembalikan kepada pemanggil function.
Nilai yang dikembalikan tersebut disebut return value. Sedangkan
nilai yang dimasukkan ke dalam function ($a dan $b) disebut
parameter.
C. Deklarasi function
Ada beberapa hal utama yang perlu diperhatikan dalam deklarasi
function pada PHP.
nama function
parameter
function body
Contoh function:
1 function addNumber($x, $y)
2 {
3 z = x + y;
4 echo(z);
5 }
6
7 function jumlahkanlah(int x, int y)
8 {
9 z = x + y;
10 return z;
11 }
Perhatikan contoh function addNumber di atas.
38
Baris satu merupakan deklarasi function. deklarasi berisi :
- keyword function
- nama function
- parameter
Parameter adalah nilai yang dimasukkan ke dalam function untuk
diproses sehingga menghasilkan output.
Nama function ditentukan dengan memenuhi aturan sebagai berikut :
Tidak boleh sama dengan function yang telah ada dalam PHP.
Hanya boleh terdiri dari huruf, angka, dan garis bawah (underscore)
Tidak boleh diawali dengan angka
function 4uOnly(){} // tidak boleh
bahasa pemrograman lain mendukung fasilitas overloading, yaitu sebuah
function dapat memiliki nama yang sama dan hasil yang berbeda,
dengan syarat parameternya berbeda. PHP tidak mendukung overloading.
Jadi, kita tidak dapat menggunakan nama yang telah digunakan
sebelumnya.
D. Implementasi function
Contoh function:
1 function addNumber($x, $y)
2 {
3 z = x + y;
4 echo(z);
5 }
6
7 function jumlahkanlah(int x, int y)
8 {
9 z = x + y;
10 return z;
11 }
Perhatikan contoh function addNumber di atas.
Perhatikan baris 2 sampai 4.
Function body dibatasi oleh sepasang { dan }
Function body berisi instruksi yang harus dilakukan komputer untuk
menghasilkan output yang diinginkan.
Baris 3 menyuruh komputer untuk membuat satu variabel bernama z
yang isinya adalah hasil penjumlahan x dan y.
x dan y didapat dari input yang diberikan user.
39
Baris 4 menyuruh komputer untuk menampilkan hasil perhitungan ke
layar.
Bedakan dengan baris 4 pada function jumlahkanlah yang
memerintahkan komputer untuk menampilkan hasil perhitungan di
layar
Contoh penggunaan function
hasil = jumlahkanlah(4,5);
addNumber(4,5);
40
IX. Variable Lifetime
A. Scope
Scope, lifetime, visibility adalah berbagai istilah yang sama,
menyatakan di mana variabel dapat digunakan dalam program. PHP
mengenal dua macam scope, yaitu local dan global. Variabel local hanya
dapat digunakan dalam blok tempatnya dideklarasi. Variabel global dapat
digunakan di mana saja dalam program setelah dideklarasi dan
diinisialisasi.
Local
Untuk lebih memahami scope local, perhatikan script di bawah :
<?
function testVar(){
$a = 3;
}
echo($a); // error – variabel $a tidak dikenali
?>
Variabel $a hanya berlaku di dalam function testVar, sehingga tidak
dapat diakses di luar function.
Global
Variabel global dideklarasi di luar function dan dapat digunakan di mana
saja dalam program. Variabel global tidak berlaku di dalam function
kecuali dipanggil dengan keyword global. Contoh penggunaan :
<?
$a = 4;
function testVar2(){
echo($a); // — tidak menghasilkan apa-apa
global $a;
echo($a); // — menampilkan 4
}
?>
B. Passing variabel
By Value
Variabel dipassing (dimasukkan) ke dalam function dengan cara pass
by value. Pass by value membuat kopi dari variabel yang asli. Dengan
demikian variabel asli tidak terpengaruh. Untuk lebih jelasnya, perhatikan
contoh berikut :
41
function tambahSatu($angka){
$angka++;
}
Function tersebut akan digunakan sebagai berikut :
<?
$a = 7;
tambahSatu($a);
echo(“Nilai a = ” . $a);
?>
kode di atas akan menghasilkan output
Nilai a = 7
karena variabel angka yang ada dalam function berakhir umurnya pada
saat function selesai dijalankan. Dan variabel a yang asli tetap bernilai 7.
Untuk menghasilkan efek yang diinginkan, kita dapat menggunakan pass
by reference.
By Reference
Pada pass by reference, kita memasukkan variabel yang asli ke dalam
function. Teknik ini dilakukan dengan cara sebagai berikut :
function tambahSatu(&$angka){
$angka++;
}
Function tersebut akan digunakan sama seperti contoh di atas :
<?
$a = 7;
tambahSatu($a);
echo(“Nilai a = ” . $a);
?>
kode di atas akan menghasilkan output
Nilai a = 8
42
X. Class dan Objects
Aplikasi perangkat lunak dibuat untuk menyelesaikan masalah dalam
kehidupan nyata. Dalam proses perancangannya, ada beberapa
pendekatan y ang dipakai.
Sekuensial Programming
Structured Programming
Object Oriented Programming
A. Konsep class dan object
Untuk dapat memahami class dan object, kita akan memvisualisasikan
aplikasi address book.
Dalam sebuah address book, komponen utama yang terlibat adalah
kontak
Komponen kontak disebut class.
Class adalah definisi (cara menggambarkan) suatu benda.
Object adalah benda nyata yang ada dalam session pelatihan,
diantaranya:
Kontak : Charlie, Budi, Ani
Hubungan tersebut dapat dinyatakan dalam istilah teknis sebagai berikut:
Object merupakan instance dari class.
Class didefinisikan dengan kode sebagai berikut :
<?
class Contact{
}
?>
object dari class Contact dibuat dengan kode sebagai berikut :
$ani = new Contact();
$budi = new Contact();
$charlie = new Contact();
B. Method dan properties
Lebih mendetail tentang class Contact. Semua contact, baik Ani, Budi,
maupun Charlie, mempunyai karakteristik yang sama. Mereka semua
memiliki nama lengkap, nomer telepon, dan alamat. Karakteristik ini
43
dikenal dengan istilah properties. Properties diterjemahkan ke dalam
kode menjadi :
<?
class Contact{
var $namaLengkap;
var $telp;
var $alamat;
}
?>
Tiap object memiliki nilai yang berbeda-beda untuk masing-masing
properties. Hal ini juga sering dikatakan : object memiliki state yang
berbeda satu dengan lainnya. Sampel kode yang menggambarkan
kondisi tersebut adalah :
$ani = new Contact();
$ani->namaLengkap = “Ani Malia”;
$ani->telp = 528;
$ani->alamat = “Ragunan”;
$budi = new Contact();
$budi->namaLengkap = “Budi Man”;
$budi->telp = 456;
$budi->alamat = “Bandung”;
$charlie = new Contact();
$charlie->namaLengkap = “Charlie Charmless”;
$charlie ->telp = 123;
$charlie ->alamat = “USA”;
selain menyimpan karakteristik, class juga dapat melakukan aktivitas. Ini
disebut dengan method. Misalnya, class Contact dapat melakukan
aktivitas memanggil contact lain. Konsep ini diterjemahkan menjadi kode
sebagai berikut :
<?
class Contact{
var $namaLengkap;
var $telp;
var $alamat;
function panggil($contact){
echo(“Memanggil kontak ”+$contact->namaLengkap);
}
}
?>
kode tersebut dieksekusi sebagai berikut :
44
$ani = new Contact();
$ani->namaLengkap = “Ani Malia”;
$budi = new Contact();
$budi->panggil($ani);
dan menghasilkan output sebagai berikut :
Memanggil Ani Malia
45
XI. File Handling
Pada bagian ini, kita akan mempelajari bagaimana script php berinteraksi
dengan file. Sebagai contoh, kita akan meneruskan aplikasi contact manager
dengan memungkinkan pengguna untuk mengupload file foto beserta
komentarnya. Setelah foto berhasil diupload, kita akan memberikan halaman
untuk mengakses foto dan komentar tersebut.
Sebelumnya, form HTML yang dibutuhkan harus disiapkan dengan bentuk
sebagai berikut :
form tersebut harus dapat menghandle file upload. Listing kode upload.htm
adalah sebagai berikut :
46
<html>
<head>
<title>Pic Uploader</title>
</head>
<body>
<h1>Pic Uploader</h1>
<form enctype=”multipart/form-data” method=”POST”
action=”upload.php”>
<p>Nama anda&nbsp; : <input type=”text”
name=”nama”>&nbsp;&nbsp; </p>
<p>Masukkan foto anda&nbsp; : <input type=”file”
name=”pic”>&nbsp;&nbsp; </p>
Komentar : <br><TEXTAREA ROWS=5 COLS=40
name=”comment”></TEXTAREA>
<p><input type=”submit” value=”Submit” name=”B1″></p>
</form>
</body>
</html>
A. Menulis file
Sekarang kita akan mengerjakan file upload.php yang berguna untuk
menangani file upload dari form tersebut.
Sebagai contoh, kita akan mengisi form tersebut sebagai berikut :
47
Form tersebut, setelah diisi dan disubmit, akan diterima oleh server dan
menghasilkan beberapa variabel berikut :
Nama
Variabel
Keterangan Isi
$nama Berisi tulisan yang diisikan user di
textfield nama anda
Endy Muhardin
$comment Berisi tulisan yang diisikan user di
textarea komentar
Ini foto saya waktu kecil
$pic Berisi file gambar yang diupload,
disimpan sementara di server

$pic_name Berisi nama file yang diupload Coffee Bean.bmp
$pic_size Berisi ukuran file yang diupload 16.6 kB
Informasi di atas dapat kita tampilkan dalam script upload.php dengan
kode sebagai berikut :
echo(“Nama File User = $pic_name <br>”);
echo(“Nama File User di server= $pic <br>”);
echo(“Ukuran File User = $pic_size <br>”);
echo(“Jenis File User = $pic_type <br>”);
File yang akan kita tulis ke harddisk berada dalam variabel $pic. File ini
akan kita copy untuk disimpan secara permanen dalam disk. Untuk itu,
kita akan menambah kode berikut pada upload.php :
$fileServer = “upload/$nama/$pic_name”;
copy($pic, $fileServer);
Selain file gambar yang diupload, kita juga akan menuliskan komentar
yang ada di textarea ke dalam file, dengan nama yang sama dengan
nama gambar, diakhiri dengan extension txt untuk menandai bahwa file
tersebut mempunyai format text.
Untuk menulis ke dalam file, lakukan langkah-langkah berikut :
Buka/buat file
Untuk dapat mengakses dan mengubah isi file, kita membutuhkan
sebuah file descriptor. File descriptor adalah suatu variabel yang
digunakan untuk mewakili file tertentu.
File descriptor didapat dengan menggunakan fungsi php : fopen, untuk
membuka file.
File yang akan kita buat akan diberi nama sesuai dengan nama gambar.
Tambahkan kode berikut pada upload.php
48
$fileComment = “/upload/$nama/$pic_name-comment.txt”;
$fp = fopen($fileComment, “w”);
seperti kita lihat pada contoh di atas, kita menggunakan fungsi fopen.
Fungsi ini membutuhkan dua masukan (parameter), yaitu : nama file,
dan jenis akses.
Nama File : bertipe string, merupakan nama file yang akan dibuka.
Harus berada dalam folder yang sama dengan tempat script php
yang memanggilnya.
Jenis Akses : bertipe string, menentukan perlakuan yang
diperbolehkan terhadap file yang dibuka. Ada beberapa jenis akses:
Read : disimbolkan dengan huruf r. File yang dibuka hanya dapat
dibaca dan tidak boleh ditulisi. File yang dibuka dengan akses r akan
menimbulkan pesan error kalau ada usaha untuk menulis ke
dalamnya.
Write : disimbolkan dengan huruf w. File yang dibuka hanya dapat
ditulis dan tidak bisa dibaca. Penulisan terhadap file akan
menghapus isi yang sebelumnya.
Read dan write : disimbolkan dengan r+. File yang dibuka dapat
dibaca dan juga ditulisi. Penulisan terhadap file akan ditambahkan
pada bagian awal file.
Write dan read : disimbolkan dengan w+. Apabila file sudah ada,
isinya akan dihapus.
Menambahkan (append) : disimbolkan dengan a. Membuka
(membuat bila belum ada) dan menulis di awal file.
Menambahkan (append) dan membaca: disimbolkan dengan a+.
Membuka (membuat bila belum ada) dan menulis di awal file.
Mode binary. Disimbolkan dengan b. Digunakan pada filesystem
windows yang membedakan file text dan binary.
Masukkan data
Setelah file berhasil dibuka/dibuat, masukkan data ke dalamnya.
Perintahnya adalah sebagai berikut :
fwrite($fp, $comment);
49
Tutup file
Setelah itu, tutup file.
fclose($fp);
B. Menghapus file
File yang dupload pada pembahasan di atas telah tersimpan secara
permanen di harddisk server di folder upload/endymuhardin/Coffee
Bean.bmp. dengan demikian, kita dapat menghapus file yang disimpan
sementara oleh server. File tersebut kita hapus dengan menggunakan
perintah unlink() atau delete(). Tambahkan baris berikut pada
upload.php.
unlink($pic);
C. Membuat direktori
Pembaca yang teliti akan menyadari bahwa nama folder pada contoh di
atas disesuaikan dengan nama user yang mengupload foto. Karena kita
sebagai programmer tidak dapat meramalkan nama user yang akan
mengupload foto, kita tidak dapat menyediakan folder yang sesuai
dengan kebutuhan tersebut. Dengan demikian, kita harus membuat
folder secara dynamic. Membuat direktori atau folder baru bukan hal
yang sulit, tambahkan baris berikut pada upload.php :
$oldmask = umask(0);
mkdir(“upload/$nama”, 0777);
umask($oldmask);
direktori akan dibuat dengan nama folder sesuai dengan nama user
yang dimasukkan pada form dengan permission 777. Arti dari permission
777 dan umask tidak dibahas dalam tutorial ini.
D. Navigasi direktori
Selanjutnya, kita akan menampilkan foto yang telah diupload oleh user.
Untuk itu, kita harus membuka folder yang berisi file, melihat daftar file
yang ada, dan menampilkan foto serta isi comment.
Untuk menampilkan foto, kita cukup memberikan link nya saja dalam
tag <img> </img>. Sedangkan untuk menampilkan isi file text, kita
harus membuka dan membaca file txt tersebut.
50
Untuk menampilkan isi direktori, kita terlebih dulu harus membuka
direktori. Tambahkan kode berikut pada upload.php :
$myDir = “upload/$nama”;
$dir = opendir($myDir);
Direktori yang telah terbuka akan disimpan dalam variabel $dir.
Selanjutnya, kita akan melakukan looping untuk membaca setiap entry
yang ada dalam folder. Tambahkan kode berikut :
echo(“Isi folder upload/$nama : <br>”);
while($tmp = readdir($dir)){
echo($tmp.”<br>”);
}
Setelah selesai, tutup folder dengan kode berikut:
closedir($dir);
E. Menghapus direktori
Untuk menghapus direktori, gunakan kode berikut :
rmdir($namaDirektori);
direktori yang akan dihapus harus kosong.
F. Membaca file
Untuk menampilkan isi comment yang telah kita tulis ke dalam file, kita
akan menempuh langkah-langkah yang sama dengan menulis file, yaitu:
Buka file – baca isinya – tutup file.
Ada sedikit modifikasi, kita akan memproses isi comment agar tidak
mengandung tag-tag html. Tambahkan kode berikut pada upload.php :
$f = fopen($fileComment, “r”);
$isi = fread($f, filesize($fileComment));
fclose($f);
$output = nl2br(htmlspecialchars($isi));
echo(“Komentar anda : <br>”);
echo($output);
demikianlah isi file ditampilkan.
51
File lengkap upload.php adalah sebagai berikut :
<?
// — Upload File — //
// info tentang file user :
echo(“Nama File User = $pic_name <br>”);
echo(“Nama File User di server= $pic <br>”);
echo(“Ukuran File User = $pic_size <br>”);
echo(“Jenis File User = $pic_type <br>”);
// menulis file pic ke harddisk server
$oldmask = umask(0);
mkdir(“upload/$nama”, 0777);
umask($oldmask);
$fileGambar = “upload/$nama/$pic_name”;
copy($pic, $fileGambar);
// menulis file comment ke file
$fileComment = “upload/$nama/$pic_name-comment.txt”;
$fp = fopen($fileComment, “w”);
fwrite($fp, $comment);
fclose($fp);
// — Menampilkan isi folder — //
$myDir = “upload/$nama”;
$dir = opendir($myDir);
echo(“<hr>Isi folder upload/$nama : <br>”);
while($tmp = readdir($dir)){
echo($tmp.”<br>”);
}
closedir($dir);
// — menampilkan pic yang telah diupload — //
echo(“<hr>Pic $nama : <br>”);
echo(“<img src=”$fileGambar” border=0 width=100
height=100>”);
// — menampilkan isi file text –//
echo(“<hr>Komentar : <br>”);
$f = fopen($fileComment, “r”);
$isi = fread($f, filesize($fileComment));
fclose($f);
$output = htmlspecialchars($isi);
echo($output);
?>
52
XII. Database Access
Menyimpan data dalam file biasa memiliki banyak keterbatasan. Semakin
besar ukuran file, pencarian data menjadi lebih sulit. File biasa juga tidak
memiliki kemampuan untuk mengolah data, misalnya menghitung total nilai,
rata-rata, dan lain sebagainya.
Dan yang lebih penting, adanya keterbatasan untuk mengendalikan akses
terhadap data. Kita tidak dapat menentukan siapa yang boleh dan siapa yang
tidak boleh mengakses data. Siapa yang boleh membaca dan tidak boleh
menulis, dan sebagainya.
Karena itu, sekarang kita akan menggunakan media penyimpanan data yang
lebih mutakhir, yaitu database. Operasi data dalam database umumnya
mengikuti pola yang sama, yaitu melalui rangkaian langkah sebagai berikut :
Membuka sambungan dengan database server
Memilih dan membuka database yang diinginkan
Mengirim perintah untuk mengambil/mengubah/menghapus data.
Mengakses hasil pengambilan data
Mengakhiri sambungan
Kita akan membahas masing-masing langkah tersebut satu per satu.
Sebagai contoh, kita akan mengaktifkan fasilitas login pada aplikasi Contact
Manager. User akan diminta untuk memasukkan username dan password.
Bila data yang dimasukkan sama dengan yang ada dalam database, user
akan diteruskan ke halaman welcome. Kalau salah, akan muncul pesan error.
Sebagai tambahan, kita akan membuat halaman yang memungkinkan user
untuk mengganti password.
User yang belum terdaftar dapat melakukan registrasi di halaman yang akan
disediakan. Berikut screenshot halaman web yang dibutuhkan :
53
login.htm :
register.htm
54
A. Sekilas SQL Query
SQL (Structured Query Language) adalah bahasa yang khusus
digunakan untuk mengoperasikan database. Untuk memudahkan
pelajaran, SQL query akan dikelompokkan menjadi tiga:
Query untuk mengelola database
Query untuk mengakses data dalam satu tabel
Query yang melibatkan lebih dari satu tabel
Query pengelolaan database
Yang termasuk ke dalam kelompok ini adalah query yang bertujuan
untuk :
Membuat database
Menghapus database
Membuat tabel
Memodifikasi tabel
Menghapus tabel
Menambah user
Mengatur permission
Menghapus user
Membuat database dilakukan dengan perintah sebagai berikut :
CREATE DATABASE <nama database>
Contohnya : untuk aplikasi Content Management, kita akan membuat
database ContentManager dengan query sebagai berikut :
CREATE DATABASE ContactManager
Menghapus database dilakukan dengan perintah :
DROP DATABASE <nama database>
Contoh :
DROP DATABASE ContactManager
Membuat tabel dilakukan dengan memberikan perintah sebagai berikut:
CREATE TABLE <nama tabel> (
<nama kolom> <tipe data>,
<nama kolom> <tipe data>,
… ,
<nama kolom> <tipe data>
);
contohnya:
55
CREATE TABLE userTable(
UserId INT (3),
UserName VARCHAR (50),
Password VARCHAR (50),
NamaLengkap VARCHAR (50)
);
Menghapus tabel dilakukan dengan menggunakan query
DROP TABLE <nama tabel>;
Contoh :
DROP TABLE userTable;
Query satu tabel
Query satu tabel digunakan untuk mengelola data dalam satu tabel.
Beberapa hal yang dapat dilakukan pada satu tabel adalah :
Tujuan Query
Memasukkan data INSERT
Memodifikasi data UPDATE
Mengambil data SELECT
Menghapus data DELETE
Menghitung banyaknya data COUNT
Menghitung penjumlahan data SUM
Menghitung nilai minimal MIN
Menghitung nilai maksimal MAX
Menghitung nilai rata-rata AVG
Untuk memasukkan data ke dalam database, kita menggunakan perintah
INSERT. Aturan penulisannya adalah :
INSERT INTO <nama tabel> (<nama kolom 1>, < nama kolom
1>, ..)
VALUES (<isi kolom 1>, <isi kolom 2>, ..);
Contoh :
INSERT INTO userTable VALUES (
1,
‘endy’,
‘inipaswod’,
‘Endy Muhardin’
);
Untuk mengubah data dalam database, digunakan perintah UPDATE,
dengan aturan penulisan sebagai berikut :
UPDATE <nama tabel>
SET <nama kolom>=<isi kolom>
WHERE <kriteria>
Contoh :
56
UPDATE userTable
SET password=’test’
WHERE UserName=’endy’
Untuk menampilkan data dalam tabel, gunakan perintah SELECT. Aturan
penulisannya adalah sebagai berikut:
SELECT <nama kolom>
FROM <nama tabel>
WHERE <kriteria>
Contoh :
SELECT *
FROM UserTable
WHERE UserId=1
Untuk menghapus data dari dalam tabel, gunakan perintah DELETE.
Aturan penulisannya adalah :
DELETE FROM <nama tabel> WHERE <kriteria>
Contoh :
DELETE FROM UserTable
WHERE NamaLengkap=’Endy Muhardin’
Query banyak tabel
Query banyak tabel digunakan untuk menghubungkan data di lebih dari
satu database. Pembahasan tentang join berada di luar materi PHP
Programming dan ada di pembahasan tentang relational database.
B. Membuat koneksi ke database
Sebelum mulai, kita terlebih dahulu akan membuat database. Kita
membutuhkan tabel user untuk menyimpan data sebagai berikut :
Nama Field Tipe Data
UserId int(3)
UserName varchar(50)
Password varchar(50)
NamaLengkap varchar(50)
Tabel dibuat dengan memberikan query sebagai berikut:
CREATE TABLE userTable(
UserId INT (3) AUTO_INCREMENT PRIMARY KEY,
UserName VARCHAR (50),
Password VARCHAR (50),
NamaLengkap VARCHAR (50)
);
tabel siap digunakan.
Kita akan mulai dengan halaman daftar, karena kita belum punya user.
File register.php akan menangani pendaftaran user baru. Tugasnya
adalah memasukkan data yang diisi dalam form ke dalam database.
57
Selanjutnya, kita akan melakukan langkah-langkah seperti yang
disebutkan di atas.
Membuka sambungan dengan database server
Untuk membuka sambungan, kita membutuhkan alamat server serta
username dan password untuk database.
Setelah itu, kita membuka sambungan dengan perintah sebagai berikut :
$dbServer = “localhost”;
$dbUser = “endy”;
$dbPass = “test”;
$dbConn = mysql_pconnect($dbServer, $dbUser, $dbPass);
sambungan dengan database disimpan dalam variabel $dbConn untuk
digunakan pada langkah-langkah selanjutnya.
Memilih dan membuka database yang diinginkan
Selanjutnya, kita akan menggunakan database tutorial, yang sebelumnya
telah dibuat dengan menggunakan PHPMyAdmin. Gunakan kode berikut
untuk memilih dan membuka database phpTutorial.
$dbName = “phpTutorial”;
mysql_select_db($dbName);
sekarang database telah siap untuk digunakan. Kita dapat melangkah ke
tahap selanjutnya, yaitu memasukkan data.
Mengirim perintah untuk
mengambil/mengubah/menghapus data.
Perintah untuk memasukkan data dibuat dengan menggunakan aturan
SQL, dijelaskan lebih lengkap pada bagian selanjutnya. Query (perintah)
untuk memasukkan data adalah :
INSERT INTO userTable VALUES (
1,
‘endy’,
‘inipaswod’,
‘Endy Muhardin’
);
perintah tersebut dieksekusi di dalam script PHP sebagai berikut :
58
$query = “
INSERT INTO userTable VALUES (
1,
‘endy’,
‘inipaswod’,
‘Endy Muhardin’
);
“;
$hasil = mysql_query($query);
if($hasil){
echo(mysql_affected_rows().” orang ditambahkan ke dalam
sistem”);
}
Script kita harus mengambil data dari HTML Form (register.htm) dan
memasukkannya ke dalam database. Untuk itu, kita akan membuat file
register.php yang berisi kode sebagai berikut :
<?
$dbServer = “localhost”;
$dbUser = “endy”;
$dbPass = “test”;
$dbConn = mysql_pconnect($dbServer, $dbUser, $dbPass);
$dbName = “phpTutorial”;
mysql_select_db($dbName);
$query = “
INSERT INTO userTable
(UserName, Password, NamaLengkap)
VALUES (
‘$user’,
‘$pass’,
‘$namaLengkap’
);
“;
$hasil = mysql_query($query);
if($hasil){
echo(mysql_affected_rows().” orang ditambahkan ke dalam
sistem”);
}
?>
C. Mengakses hasil query
Setelah register.htm dieksekusi dengan sukses, kita telah memiliki satu
user dalam database. Dengan demikian, kita dapat menguji halaman
login yang telah kita buat. Untuk itu, kita perlu mengakses data dalam
database dan mencocokkannya dengan input yang diberikan user.
Langkah-langkah untuk mengakses data dalam database adalah :
59
Membuat sambungan database
Memilih database
Membuat query
Menjalankan query
Mengambil hasilnya
Memproses hasil
Query yang akan digunakan adalah :
SELECT * FROM UserTable WHERE userName=’input dari user’
Query ini akan dimasukkan ke dalam script menjadi :
$query = SELECT * FROM UserTable WHERE userName=’$login’
Dan dieksekusi dengan kode :
$hasil = mysql_query($query);
Bila userName yang diinputkan user tidak ada dalam database, query
akan mengembalikan 0 (nol) baris hasil. Bila ada, query akan
menghasilkan array yang berisi data pada masing-masing kolom dalam
database.
Untuk mengetahui jumlah hasil yang didapat dari query, digunakan
kode sebagai berikut:
$jumlahHasil = mysql_num_rows($hasil);
Apabila hasilnya tidak nol (berarti username telah terdaftar dalam
sistem), kita akan mengambil data password. Untuk itu, kita gunakan
perintah:
$data = mysql_fetch_array($hasil);
data password ada dalam array, diakses dengan cara :
$passDb = $data[“Password”];
60
Dengan demikian, keseluruhan script login.php akan menjadi :
<?
// variabel yang diperlukan untuk akses database
$user = “endy”;
$pass = “test”;
$db = “ContentManager”;
$server = “localhost”;
// membuat koneksi
$koneksi = mysql_connect($server, $user, $pass);
// memeriksa koneksi
if(!$koneksi){
echo(“Koneksi ke database gagal”);
exit;
}
// membuka database
mysql_select_db($db);
// membuat query
$query = “SELECT * FROM userTable WHERE
userName=’”.$login.”‘”;
// mengeksekusi query
$hasil = mysql_query($query);
// mengakses hasil
$jumlahHasil = mysql_num_rows($hasil);
if($jumlahHasil < 1){
echo(“User $login tidak ada dalam database <br>”);
}else{
echo(“User $login ada dalam database<br>”);
$data = mysql_fetch_array($hasil);
$passwordAsli = $data["password"];
if($password == $passwordAsli){
echo(“Password untuk user $login benar<br>”);
}else{
echo(“Password untuk user $login salah<br>”);
}
}
?>
61
XIII. String Handling
String handling adalah kumpulan function PHP yang berguna untuk
memanipulasi string. Ada banyak kegunaan yang bisa didapat dengan
menggunakan fungsi-fungsi ini, misalnya:
Pencarian kata dalam website
Pemeriksaan user input
Memformat file untuk keperluan khusus (misalnya email).
Dan sebagainya
A. Sekilas Regular Expression
Untuk dapat menggunakan fungsi-fungsi string handling dengan baik,
kita perlu menguasai teknik pembuatan pola kalimat. Contoh pola kalimat
misalnya, alamat email yang valid (misalnya endy@ngoprek.org) selalu
memiliki pola sebagai berikut:
satu atau lebih huruf/angka, diikuti tanda @ kemudian diikuti dengan
satu atau lebih huruf/angka, dipisahkan oleh tanda titik, lalu diakhiri
dengan satu atau lebih huruf/angka.
Pola tersebut, dapat dinyatakan dengan seperangkat kode sebagai
berikut :
Pola kode
Harus di awal kata ^
Huruf A-Za-z
Angka 0-9
Huruf atau angka [A-Za-z0-9]
Semua jenis karakter .
Berjumlah satu atau lebih + atau {1,}
Berjumlah nol atau lebih * atau {0,}
Berjumlah tiga sampai sepuluh {3,10}
Diikuti dengan @ @
Tanda titik .
Harus berada di akhir kalimat $
Pola alamat email di atas dapat dinyatakan dengan satu baris kode
sebagai berikut.
^.+@.+..+$
62
Atau kita dapat membatasi alamat email yang digunakan oleh user agar
hanya menerima domain com, net, atau edu dengan menggunakan pola
berikut :
^.+@.+.((com)|(edu)|(net))$
B. Penggunaan Regular Expression
Untuk mendemonstrasikan kemampuan string handling, kita akan
menggunakan input form yang akan memvalidasi alamat email dan
nomer telepon yang dimasukkan user.
CekMail.htm berbentuk seperti gambar di bawah:
input yang dimasukkan user akan diperiksa oleh script CekMail.php
yang berisi kode sebagai berikut :
<?
// validasi alamat email
$polaEmail = “^.+@.+..+$”;
if(!eregi($polaEmail, $email)){
echo(“Masukkan alamat email yang valid, misal :
endy@ngoprek.org”);
}else{
echo(“Alamat email valid”);
}
// validasi no telp
$polaTelp = “^+[0-9]{2}-[0-9]+$”;
if(!eregi($polaTelp, $telp)){
echo(“Masukkan nomer telepon yang valid, misal : +62-
315054307″);
}else{
echo(“No telp valid”);
}
?>
63
Function yang digunakan untuk memeriksa email pada script di atas
adalah eregi. Menerima input berupa pola yang diinginkan dan string
yang akan diperiksa. Function ini akan menghasilkan nilai true bila
polanya sesuai dan false bila pola yang dicari tidak ada pada string input.
64
XIV. Session
A. No Session
Pada waktu kita browsing menjelajahi website, misalnya e-mail, kita akan
diminta memasukkan username dan password. Prosedur ini hanya dilakukan
sekali pada awal proses. Selanjutnya sistem akan ‘mengingat’ identitas kita,
dan menampilkan informasi yang sesuai. Tanpa adanya session, sistem akan
salah dan menampilkan data rahasia ke orang yang salah.
Untuk mengetahui kegunaan session, kita akan membuat aplikasi tanpa
session. Kita membutuhkan satu halaman web dan tiga script php : login.htm,
loginNoSession.php, welcomeNoSession.php dan displayNoSession.php
login.htm
<html>
<head>
<title>Login</title>
</head>
<body>
<h1>Login </h1>
<form method=”POST” action=”loginNoSession.php”>
<table border=”1″ width=”44%”>
<tr>
<td width=”27%”>user : </td>
<td width=”73%”><input type=”text” name=”login”
size=”20″></td>
</tr>
<tr>
<td width=”27%”>password : </td>
<td width=”73%”><input type=”text” name=”pass”
size=”20″></td>
</tr>
<tr>
<td width=”27%”>&nbsp;</td>
<td width=”73%”><input type=”submit” value=”Submit”
name=”B1″><input type=”reset” value=”Reset” name=”B2″></td>
</tr>
</table>
</form>
<p><a href=”register.htm”>Daftar</a></p>
</body>
</html>
65
loginNoSession.php
<?
// — cek user dan password — //
if($login == “endy” && $pass ==”test”){
header(“Location: welcomeNoSession.php?user=endy”);
}elseif($login == “oky” && $pass ==”coba”){
header(“Location: welcomeNoSession.php?user=oky”);
}else{
echo(“User dan password salah”);
}
?>
welcomeNoSession.php
<?
echo(“Welcome $user <br>”);
echo(“<a href=”displayNoSession.php?user=$user”>”);
echo(“klik di sini untuk mengakses daftar kenalan
anda</a>”);
?>
displayNoSession.php
<?
$dbUser = “endy”;
$dbPass = “test”;
$db = “latihan”;
$server = “localhost”;
// membuat koneksi
$koneksi = mysql_connect($server, $dbUser, $dbPass);
// memeriksa koneksi
if(!$koneksi){
echo(“Koneksi ke database gagal”);
exit;
}
// membuka database
mysql_select_db($db);
// membuat query dan mengakses hasil
$query = “SELECT * FROM UserData WHERE user=’$user’”;
$hasil = mysql_query($query);
// menampilkan hasil
echo(“<table border=1>”);
echo(“<tr>”);
echo(“<td>NamaTeman</td>”);
echo(“<td>Keterangan</td>”);
echo(“</tr>”);
while($row = mysql_fetch_array($hasil)){
echo(“<tr>”);
echo(“<td>”.$row["namaTeman"].”</td>”);
echo(“<td>”.$row["keterangan"].”</td>”);
echo(“</tr>”);
}
echo(“</table>”);
?>
66
kode ini membutuhkan data contact yang diambil dari tabel UserData
dengan definisi sebagai berikut:
CREATE TABLE userData (
user VARCHAR(50),
namaTeman VARCHAR(50),
keterangan VARCHAR(50)
);
dan sampel data sebagai berikut:
INSERT INTO userData VALUES (
‘endy’,
‘Imanudin’,
‘Teman ceting’
);
INSERT INTO userData VALUES (
‘oky’,
‘Iswahyudi’,
‘Pak Lurah kos adhyaksa’
);
INSERT INTO userData VALUES (
‘oky’,
‘Anton Raharja’,
‘Rekan kerja di kantor’
);
INSERT INTO userData VALUES (
‘endy’,
‘Widya Andhini’,
‘Gebetan lama tapi masih mesra’
);
Jalannya aplikasi :
login dengan user = oky dan password = coba
67
klik link untuk mendisplay output, tampilan akan muncul sebagai
berikut:
sekarang, kita akan “memalsu” link yang ada di address bar untuk
menampilkan data user endy.
Buka browser baru dan masukkan link berikut di address bar:

http://localhost/latihan/displayNoSession.php?user=endy

Kemudian tekan enter.
68
Ooopss… dengan mudah data rahasia akan muncul.
Cara mencegah hal ini terjadi adalah dengan meminta user untuk
memasukkan login dan password setiap kali ia berpindah halaman.
Tetapi tentu saja cara ini menjengkelkan bagi user. Selain itu,
mempassing variabel login dan password di setiap halaman sangat tidak
aman dan rentan penyadapan.
Oleh karena itulah kita menggunakan session.
B. Konsep session
Session bekerja seperti tempat penitipan barang di supermarket. Kita
datang, menitipkan barang bawaan, dan petugas akan memberikan
tanda pengenal.
Pada saat kita akan mengambil barang, kita memberikan tanda pada
petugas, dan petugas akan dapat mengambil barang yang dititipkan
tanpa tertukar dengan barang orang lain.
Permasalahan yang terjadi adalah, bagaimana “tanda pengenal”
tersebut akan disimpan pada setiap halaman yang diakses user, sehingga
dapat diakses oleh sistem setiap kali user mengklik link.
Ada tiga alternatif yang dapat digunakan untuk menyimpan data
session :
o Cookie
o Hidden Form
o URL Embedding
69
C. Implementasi : Cookie
Cookie adalah informasi yang disimpan pada browser user. Script
menjalankan function setcookie yang akan menulis data di harddisk user.
Cookie ditulis pada browser user dengan menggunakan perintah :
setcookie(“sessionId”, “1234”);
Setelah itu, variabel $sessionId akan tersedia setiap kali browser
user mengakses sistem.
Cookie akan hilang dari browser user setelah melewati masa kadaluarsa
yang ditentukan atau dihapus melalui perintah:
setcookie(“sessionId”);
Pendekatan ini banyak mengundang kontroversi. Karena cookie dapat
menghilangkan privacy user dan berpotensi mengandung virus. Oleh
karena itu, user dapat menonaktifkan cookie melalui setting di browser.
Dengan demikian, pendekatan ini kurang handal untuk diterapkan pada
aplikasi kita.
Untuk melihat dengan lebih jelas implementasi cookie, kita akan
memodifikasi aplikasi di atas sebagai berikut :
login.htm
<form method=”POST” action=”loginSessionCookie.php”>
loginSessionCookie.php
<?
// — cek user dan password — //
if($login == “endy” && $pass ==”test”){
setcookie(“user”, $login);
header(“Location: welcomeSessionCookie.php”);
}elseif($login == “oky” && $pass ==”coba”){
setcookie(“user”, $login);
header(“Location: welcomeSessionCookie.php”);
}else{
echo(“User dan password salah”);
}
?>
welcomeSessionCookie.php
70
<?
if(!$user){
echo(“Illegal Access”);
exit;
}
echo(“Welcome $user <br>”);
echo(“<a href=”displaySessionCookie.php”>”);
echo(“klik di sini untuk mengakses daftar kenalan
anda</a>”);
?>
tambahkan baris berikut pada bagian atas displayNoSession.php dan
save as displaySessionCookie.php
if(!$user){
echo(“Illegal Access”);
exit;
}
Untuk mengujinya, buka browser baru dan masukkan link berikut di
address bar:

http://localhost/latihan/displaySessionCookie.php

Kemudian tekan enter.
Anda akan mendapatkan:
Sekarang, disable cookie dengan cara :
Klik Tools – Internet Options
71
Klik tab Security dan klik tombol Custom Level
klik disable cookie
72
coba lagi mengakses halaman contact. Anda akan mendapat Illegal
Access.
D. Implementasi : Hidden Form
Cara kedua untuk menyimpan data session adalah dengan menyimpan
data tersebut pada hidden input yang ada dalam form. Misalnya dengan
menggunakan kode :
<input type=”hidden” name=”user” value=”$user”>
cara ini juga tidak dapat dilakukan di segala kondisi, karena ada saatsaat
di mana kita tidak dapat menggunakan form.
E. Implementasi : URL Embedding
Cara terakhir yang pasti berhasil adalah dengan “menempelkan”
variabel session di link/URL. Misalnya link menuju welcome.php
dimodifikasi menjadi welcome.php?sessionId=1234.
Satu-satunya kerugian cara ini adalah, link URL menjadi tidak bisa
di’bookmark’. Selain itu, link menjadi tidak indah dipandang mata. Tetapi
secara teknis, metode inilah yang paling efektif dan reliable.
F. Implementasi : Session API
Session API PHP menggabungkan teknik cookie dan teknik URL
Embedding. Apabila user mengaktifkan cookie, PHP akan menyimpan
data session pada cookie. Tetapi apabila cookie di-disable user, PHP akan
menyimpan data session pada URL. Mekanisme ini terjadi secara
otomatis apabila PHP dicompile dengan option –enable-trans-sid.
Cara penggunaan PHP Session API dapat dilihat pada
loginSessionApi.php, welcomeSessionApi.php, dan displaySessionApi.php.
Anda dapat memodifikasi setting Internet Explorer untuk melihat
bahwa metode ini dapat dijalankan walaupun cookie di-disable. Kita juga
tidak dapat mengetik langsung URL

http://localhost/latihan/displaySessionApi.php

untuk membuka halaman pribadi.
73
loginSessionApi.php:
<?
// — cek user dan password — //
if($login == “endy” && $pass ==”test”){
session_start();
$user = $login;
session_register(“user”);
header(“Location: welcomeSessionApi.php”);
}elseif($login == “oky” && $pass ==”coba”){
session_start();
$user = $login;
session_register(“user”);
header(“Location: welcomeSessionApi.php”);
}else{
echo(“User dan password salah”);
}
?>
welcomeSessionApi.php
<?
session_start();
if(!session_is_registered(“user”)){
echo(“Illegal Access”);
exit;
}
echo(“Welcome $user <br>”);
echo(“<a href=”displaySessionApi.php”>”);
echo(“klik di sini untuk mengakses daftar kenalan
anda</a>”);
?>
74
displaySessionApi.php
<?
session_start();
if(!session_is_registered(“user”)){
echo(“Illegal Access”);
exit;
}
$dbUser = “endy”;
$dbPass = “test”;
$db = “latihan”;
$server = “localhost”;
// membuat koneksi
$koneksi = mysql_connect($server, $dbUser, $dbPass);
// memeriksa koneksi
if(!$koneksi){
echo(“Koneksi ke database gagal”);
exit;
}
// membuka database
mysql_select_db($db);
// membuat query dan mengakses hasil
$query = “SELECT * FROM UserData WHERE user=’$user’”;
$hasil = mysql_query($query);
echo($sessionId);
// menampilkan hasil
echo(“<table border=1>”);
echo(“<tr>”);
echo(“<td>NamaTeman</td>”);
echo(“<td>Keterangan</td>”);
echo(“</tr>”);
while($row = mysql_fetch_array($hasil)){
echo(“<tr>”);
echo(“<td>”.$row["namaTeman"].”</td>”);
echo(“<td>”.$row["keterangan"].”</td>”);
echo(“</tr>”);
}
echo(“</table>”);
?>

Posted in Komputer | 1 Comment »

Menguasai Adobe Photoshop 7.0

Posted by biznizonline on February 28, 2008

Kuliah Berseri IlmuKomputer.Com
Copyright © 2003 IlmuKomputer.Com
Menguasai Adobe Photoshop 7.0
Eko Purwanto (Webmedia Training Center Medan)
1
Menguasaii Adobe
Phottoshop 7..0
Eko Purwanto
epurwanto@webmediacenter.com
WEBMEDIA Training Center Medan
www.webmediacenter.com
Modull 1
Pengenallan Photoshop 7..0
1.1 Fasilitas Terbaru Adobe Photoshop 7.0
Adobe Photoshop 7.0 menyediakan tool-tool yang terintegrasi dan tertata secara praktis untuk
menciptakan dan menghasilkan karya dalam bentuk vektor dan teks yang sempurna. Bentuk grafik yang
berdasarkan vektor dan teks bisa ditransfer menjadi image yang berdasarkan pixel untuk mendapatkan
efek desain yang lebih sempurna.
Lisensi Dokumen:
Copyright © 2003 IlmuKomputer.Com
Seluruh dokumen di IlmuKomputer.Com dapat digunakan, dimodifikasi dan
disebarkan secara bebas untuk tujuan bukan komersial (nonprofit), dengan syarat
tidak menghapus atau merubah atribut penulis dan pernyataan copyright yang
disertakan dalam setiap dokumen. Tidak diperbolehkan melakukan penulisan ulang,
kecuali mendapatkan ijin terlebih dahulu dari IlmuKomputer.Com.
Kuliah Berseri IlmuKomputer.Com
Copyright © 2003 IlmuKomputer.Com
Menguasai Adobe Photoshop 7.0
Eko Purwanto (Webmedia Training Center Medan)
2
1.2 Mengenal Area Kerja
Gambar 1.1 Area Kerja Adobe Photoshop 7.0
Area kerja Photoshop 7.0 terdiri dari Menu bar, Option bar, Toolbox, Layer, Palet, Status bar.
a. Toolbox, terdiri dari seperangkat fasilitas untuk mengedit atau memanipulasi image.
b. Option Bar, Tampilan option bar akan berubah secara dinamis sesuai tool yang digunakan.
Tampilan Option Bar dengan Tool Marquee
Tampilan Option Bar dengan Tool Magic Wand
C. Perintah View
Berfungsi untuk memperbesar atau memperkecil tampilan sesuai dengan yang kita inginkan
d. Palet Navigator
Berfungsi menggeser atau memperbesar gambar melalui sebuah salinan miniatur gambar. Bagian
tengah palet navigator disebut Thumbnail.
e. Penggaris untuk menampilkan klik View > Show Rulers (Ctrl + R), ukuran penggaris adalah
pixel.
1.3 Mode Dan Model Warna
Mode warna menentukan model warna yang digunakan untuk menampilkan dan mencetak suatu image.
a. RGB (Red, Green, Blue): Persentase yang sangat besar dari spektrum yang terlihat dapat
direpresentasikan dengan mencampur merah, hijau dan biru (Red, Green dan Blue) yang diberi
warna terang dalam berbagai proporsi dan intensitas. Dengan mencampur warna merah, hijau dan
Palet Navigator
Toolbox
Layer
Status Bar
Palet Color
Palet Layer
Option Bar
Kuliah Berseri IlmuKomputer.Com
Copyright © 2003 IlmuKomputer.Com
Menguasai Adobe Photoshop 7.0
Eko Purwanto (Webmedia Training Center Medan)
3
biru akan menciptakan warna putih. 0Ieh karena itu model RGB juga disebut dengan additive
colors (warna campuran).
b. CMYK (Cyan, Magenta, Yellow, Black): CMYK didasarkan pada kualitas penyerapan cahaya
dari tinta yang dicetak pada kertas. MisaInya, warna putih terang menyebabkan tinta menjadi
tembus pandang, sebagian dari spektrumnya diserap, dan yang lainnya K pada CWK direfleksikan
kembali menuju mata digunakan untuk
c. Bitmap Mode: Mode ini menggunakan satu dari dua nilai warna (hitam atau putih) untuk
merepresentasikan pixel ke dalam image. Image dalam mode Bitmap biasa disebut dengan
Bitmapped 1-bit karena image tersebut memiliki kedalaman bit sebanyak 1.
d. Grayscale Mode: Mode ini menggunakan lebih dari 256 bayangan abu-abu. Setiap pixel dari
sebuah image dengan mode grayscale mempunyai nilai kecerahan (brightness) dengan range 0
(hitam) sampai 255 (putih). Nilai grayscale juga dapat diterapkan dalam persentase dengan 0%
adalah putih, dan 100% adalah hitam.
e. Duotone Mode: Mode ini menggunakan 256 warna. Pada saat mengkonversi menjadi indexed
color, Photoshop akan membuat CWT (Color Lockup Table) yang menyimpan dan mengindeks
warna dalam sebuah image. Apabila ada sebuah warna dalam image aslinya tidak muncul pada
tabel, program akan memilih warna yang terdekat dengan warna tersebut, atau mensimulasikan
warna dengan menggunakan warna yang telah tersedia.
f. Multichannel Mode: Mode ini menggunakan 256 level, dari abu-abu pada tiap channel. Image
dengan menggunakan mode Multichannel sangat berguna untuk pencetakan khusus.
1.4 Membuat Dokumen Baru
Untuk membuat dokumen baru pilih menu File > New.
Kotak Dialog Membuat Dokumen Baru
1.5 Perintah Image Size
Pilihan yang terdapat dalam kotak dialog Image Size :
- Ukuran gambar dalam memori  Semakin banyak pixel berarti ukuran file menjadi lebih besar,
baik pada disk maupun pada memori komputer.
- Dimensi Absolut  Nilai Width dan Height menunjukkan dimensi gambar pada pixel. Aktifkan
Resample Image untuk mengubah nilai.
- Dimensi Cetak  ketikkan tinggi dan lebar pada gambar yang akan dicetak.
Kuliah Berseri IlmuKomputer.Com
Copyright © 2003 IlmuKomputer.Com
Menguasai Adobe Photoshop 7.0
Eko Purwanto (Webmedia Training Center Medan)
4
Latihan Melakukan Resample Gambar
1. Buka gambar sesuai petunjuk instruktur
2. Pilih Image > Image size untuk menampilkan kotak dialog.
3. Pilih kotak cek Resample Image untuk mengubah nilai resolution dan nilai Width dan Height.
4. Ubah nilai Width dan Height.
5. Klik OK.
2. Mengubah Ukuran Cetak
Jika ingin mengubah tampilan pada halaman, dan tidak ingin mengubah jumlah pixel pada halaman,
ubah resolusi agar dapat mencetak gambar lebih besar atau lebih kecil tanpa menambah atau
mengurangi satu pixelpun.
1. Buka gambar sesuai petunjuk instruktur
2. Pilih Image > Size.
3. Matikan resample image agar tidak ada pixel yang dipengaruhi pada saat mengubah ukuran gambar.
4. Ubahlah setting ukuran output dengan memilih resolusi ideal pada table berikut ini.
PRINTER
RESOLUSI
IDEAL
TIDAK LEBIH
KURANG
DARI
TIDAK
LEBIH
TINGGI
DARI
Print laser 300 ppi 120 ppi 90 ppi 150 ppi
Print laser 600 ppi 180 ppi 135 ppi 225 ppi
Newsprint 180 ppi 135 ppi 225 ppi
Coated magazine stock 267 ppi 200 ppi 330 ppi
Printer inkjet warna 300 ppi 240 ppi 400 ppi
Super-fine coated stock 350 ppi 260 ppi 440 ppi
5. Klik OK.
1.6 Perintah Rotate Canvas.
Digunakan untuk menampilkan submenu yang berisikan pilihan untuk memutar atau membalik gambar.
Berikut ini submenu dari Rotate canvas :
- 1800   memutar gambar yang terbalik agar kembali pada kakinya, Alt + I, E, 1.
- 900 CW   memutar gambar 90 derajat searah jarum jam, Alt + I, E, 9.
- 900 CCW   memutar gambar 90 derajat berlawanan jarum jam, Alt + I, E, 0)
- Arbiritary   meluruskan gambar.
- Flip horizontal   memperbaiki teks yang terbalik (alt + I + E + H).
- Flip vertikal   membalik bagian atas dan bawah gambar (alt + I, E, V)
Kuliah Berseri IlmuKomputer.Com
Copyright © 2003 IlmuKomputer.Com
Menguasai Adobe Photoshop 7.0
Eko Purwanto (Webmedia Training Center Medan)
5
Latihan Memotong detail gambar yang tidak perlu menggunakan Tool
Crop
Tool Crop berfungsi untuk memotong sisa gambar atau elemen latar belakang yang tidak perlu.
1. Klik Icon tool crop (tekan C)
2. Gambar batas crop, geser di dalam jendela gambar untuk membuat sebuah segi empat di sekitar
bagian gambar yang ingin dipertahankan
3. Geser dalam batasan crop untuk memindahkannya.
4. Geser tangkai untuk mengubah ukuran batasan gambar, tekan shift dan geser untuk mengubah
ukurannya secara profesional.
5. Geser di luar batas crop untuk menegakkan dan memotong gambar dalam satu operasi.
6. Titik pemotongan akan menjadi titik pusat perputaran jika menggeser tangkai dengan alt atau option.
7. Klik tanda cek pada baris pilihan, pilih Image-Crop-Klik ganda dalam batas crop tekan enter.
1.7. Perintah Canvas Size
Berfungsi untuk memperbesar atau memperkecil kanvas. Pilih Image > Canvas Size dan gunakan
pilihan New Size untuk mengubah dimensi atau ukuran kanvas. Grid Anchor berfungsi untuk
memposisikan gambar pada kanvas yang telah diubah ukurannya.
1. Pilih tool 2. gambar
3. geser di dalam
untuk
i d hk
4. geser tangkai untuk
mengubah ukuran
5. geser di luar untuk
memutar
6. titik pusat
7. Klik tombol OK

Posted in Komputer | 1 Comment »

Market on the Internet

Posted by biznizonline on February 9, 2008

The Internet has become part of our lives, both personal and
business.Yet, many businesses are unsure how to use the Internet to
effectively market and grow their businesses. Costs, resource allocation,
and return on investment can seem daunting when dealing with
a business Web site, e-mail, and e-commerce in addition to the daily
pressures of managing a business.
This brochure, published in conjunction with our partner SCORE,
provides answers and resources to help you harness the most
powerful sales and marketing tools available—the Internet and the
World Wide Web.
As the world’s leading print and online directory publisher, we serve
small and medium-size businesses through Verizon SuperPages and
Verizon SuperPages.com. For years, small businesses have relied on
the Yellow Pages to reach customers. Today, however, the reach of
the Yellow Pages also includes the Internet—your connection to
customers next door and around the world.
Through Verizon’s national field force, we work hand-in-hand with
you to help your business grow. Our most recent Annual Small
Business Internet Survey shows that small-business Web sites are
increasing and e-mail communication with customers is now an
integral part of growing businesses.We will continue to provide you
the resources necessary to most effectively manage and use these
new tactics and tools.
Tools for today include the Internet Learning Tutor
(www.superpages.com/ilt), a series of online Internet courses for
everyone from beginners to advanced users. SCORE, a contributing
partner of this program, is also providing how-to columns to the
Business Center (www.business.superpages.com), a resource
section of SuperPages.com designed specifically for small and
medium-size businesses.
We wish you success in your Internet endeavors and appreciate
your business’ important role in making progress everyday.
Regards,
Katherine J. Harless
President
Verizon Information Services
5. It provides user interaction. One of the big advantages of this
medium is that it allows for immediate interaction. Users can always
send e-mail, fill out a form, enter a contest, or request information. This
immediate response is part of the excitement of browsing the Web.
A site with no “user feedback” e-mail forms, no games to play, or no
forms to fill out is a site that will soon sit “un-clicked.”
A clever site entices visitors to return often to see what’s new. One tip
to encourage repeat Web visits to your site is to program a short notice
to flash on the monitor when users click on an external link. The
message might say, “You’re leaving our site now. Bookmark this site,
so you can return easily.” Users can then choose to save the Web
address by just pulling down the “save” option on the menu bar. This is
called “bookmarking,” and it saves users from having to remember
long, awkward URLs of the sites they visit often.
How much should you pay for a site?
For an overwhelming majority (96%) of small businesses that responded
to a recent Inc survey, Web-site development costs were less than
$3,000, and the monthly fees for site maintenance averaged about $71,
with few companies (only 11%) spending more than $100 a month.
1. Do it yourself. You don’t have to be a computer whiz to build and
manage a successful Web site, nor do you have to make a huge
investment. Not counting the cost of “back-office” operations (e.g.,
order processing, billing, fulfillment, and post-sale service), which vary
widely by industry, small business owners have successfully launched
their own sites. Some smaller companies have launched for less than
$400, including domain name registration ($35), Internet access ($30),
software ($200), and set-up ($50).
2. Use a search engine or an online directory. For a monthly fee,
many search engines and online directories offer to design, market
(e.g., headings, banner ads), and host your Web site. Based on your
$$$? $$$?
Put the Web to Work
3
The number of Web sites doubles every four to five months. By
2003, the Web will have up to 80 million users logging on either
through standard Internet access accounts or online services.
Utilizing the Web becomes a business decision critical to all businesses.
Small businesses are moving online with Web sites, e-mail
marketing, and in some cases, e-commerce transaction sites.
According to eMarketer, a leading Internet research firm, 78%—or 5.9
million—of all small businesses are connected to the Internet and
nearly half have active Web sites.
Five essentials for any site. Once users find a site—through a search
engine, through the business’ marketing materials, or from a link on
another site—Web visitors expect some basic elements to a Web site.
Begin your Web venture with the five “must-have” characteristics of a
Web site, which include:
1. It delivers what it promises. Say a Web user types “car repair” into
a search engine, and AutoMile Car Mart turns up among the sites that
list “car repair” in their keyword sections. The AutoMile Car Mart site
must have more than a line reading, “Our repair shop is open 12 hours
a day” to justify listing “repair” in the keyword section. Otherwise, the
user will be angry about visiting a site that offers nothing on car repair.
Keyword justification must be backed by abundant information on your
site about that topic.
2. It loads quickly. The classic mistake that many companies make is
to include a large photo or sound or video clip on their site (e.g., the
CEO, who is saying something such as, “Welcome to our Web site; we
hope you like it”). Compared to text, graphics and sound take a long
time to load. Web users who must wait several minutes for an image
and message are bound to move on to other sites. There are many
interesting visual effects that take little time to load. For example,
skinny horizontal graphics that stretch across the screen take less time
to load than large ones that use a lot of vertical space.
3. Contact information is easy to find. In the “virtual” marketplace, it
doesn’t matter if a company is in Wilmington or Walla Walla. With the
click of the mouse, it’s just as easy for Web users to reach one as it is
the other. Because users want to know where companies are in the
real world, always list your physical location, including address, phone
and fax numbers. The information reassures the visitor that the site
belongs to an actual company. It also meets the needs of those who
still prefer to call a company or mail an order rather than e-mail it.
4. The site is frequently updated. Keeping the site refreshed is key
for companies that expect visitors to return. The Web is such a fluid
environment that visitors will quickly jump somewhere more exciting if
your site rarely changes.
Chapter 1
4
company’s needs, you may choose a customized package that includes
one or more of these services.
3. Hire a Web Designer/Developer. Web designers agree that site
investment falls into three broad categories: basic, intermediate and
complex. Basic sites usually involve up to 15 Web pages and little
high-tech work. Intermediate and complex sites cost more because,
among other reasons, they require software engineers and computer
programmers. Besides having sophisticated e-commerce features,
the pricier sites often have detailed databases that mesh with
back-end systems.
Most Web developers charge a flat fee for design and development.
However, to calculate the flat fee, the developers first determine how
much in hourly labor a site will cost to produce. Then they charge their
customers a multiple of that amount. Most web developers charge
roughly double their labor costs. One way to avoid overpaying is to
learn precisely which labor costs are involved in the construction of
your site. Has the developer used database programmers? Java
programmers? HTML writers? The labor costs associated with each of
these functions depend on the skill of the technical specialist and the
pay scale for the work. Most developers will share their fees for service
in hourly rates charged for particular tasks (e.g., copywriting from $85
to $235 an hour; database programming, $115 to $250). ■
What’s in a Name?
Choose your domain name extension based on your type of business.
.biz – businesses* .com – commercial
.info – all uses* .name – personal names
.net – organizations involved in Internet infrastructure
.org – nonprofits .pro – professions*
*new top-level domains
To register the new top-level domains, visit the following Web sites:
.biz – www.neulevel.biz .info – www.nic.info
.name – www.nic.name .pro – www.registrypro.com
Is your Web address easy to find?
If you check no to any of the items listed below, you have a checklist
for adding your Web address to your marketing materials. The more
yes answers, the better. Your basic marketing materials should feature
both your Web address and e-mail address.
Web Address Email Address
Yes No Yes No Stationery
Yes No Yes No Business cards
Yes No Yes No Marketing brochures
Yes No Yes No Window signs & vehicles
Yes No Yes No Media kits
Yes No Yes No Direct mail flyers
Yes No Yes No Yellow Pages ad
Yes No Yes No Premiums and giveaways
Yes No Yes No Follow-up surveys
Yes No Yes No Rubber address stamps
Yes No Yes No Boxes, bags, etc.
5
Win the Name Game
Chapter 2
Branding your business online begins with your domain name.
Even if you don’t plan to use the domain right away, it’s
important to reserve it. By doing this, you are reserving your
name into a registry of all the domain names on the Internet.
Secure a domain name
Names ending with .biz, .com, .info, .name, .net, or .org can be
registered through many different competing registrars. In addition,
many portals, search engines, and online directories offer services for
domain name registration. The registrars submit the contact
information to a central directory, or registry, which provides other
computers on the Internet with the information necessary to send you
e-mail or to find your Web site.
You may check for domain name registration at a number of sites,
such as www.networksolutions.com, www.register.com and
www.verisign.com. If your company’s name isn’t available as a domain,
choose something close to it; abbreviate it or try adding an initial or
hyphen. When choosing a domain name, remember that people will get
to your Web site from numerous sources, some by search engines,
others by bookmarks in their browsers. Many will try to reach your site
by typing what they think your Web address may be—a good reason to
consider every conceivable way that people might enter your site’s
address into their browsers, and reserve additional domains.
Choose a consistent Web domain
and e-mail address
What about customers who confuse e-mail and Web addresses?
Most customers are familiar enough with online addresses to recognize
that any address with an “@” is e-mail. However, you can prevent
confusion by merging the two addresses. For example, you could be
both www.petespool.com and pete@petespool.com.
Protect your domain. You will have a registration contract with the
registrar that spells out the terms under which your registration is
maintained. Each registrar has the flexibility to offer registrations in
one-year increments, along with 1-, 2-, 5-, and 10-year renewal
periods. Each can set the price it charges for registering names. The
prices vary significantly, although the cost is generally less than $35 a
year (some registrars offer discounts or free registration in connection
with other services, such as Web hosting). To identify which service
best fits your needs, visit the Web sites of several registrars (check
www.icann.org for a directory). Only those accredited by ICANN
(Internet Corporation for Assigned Names and Numbers) are authorized
to register .biz, .com, .info, .name, .net, and .org names. ICANN is the
nonprofit corporation that assumed responsibility from the U.S.
government for management of the domain name system. ■
6
Set Goals for Your Site
Chapter 3
Your Web site should be an integral part of your marketing
strategy, with specific goals for measuring its success. Once
you know the costs of setting up your site, establish a goal
for your return on the investment (ROI). This should include three
considerations: What kind of return is desired? How will it be
measured? And over what period?
The type of return doesn’t have to be solely financial. It could be to
gather a certain number of names for a mailing list, or to cut mailing or
telephone expenses by a certain amount after handing over some
customer service functions to the Web site. Perhaps you hope to cut
marketing expenses, while still posting the same sales growth.
Regardless of criteria, the return should measure the main focus of the
site. In the beginning, choose one main aspect to measure.
Once the criterion is identified, make sure that systems are in place to
measure the effectiveness. Web sales can easily be measured at a site
that handles online transactions. But how would you measure the
portion of decreased mailing expenses attributable to the site? How
would you decide if customer service functions are successful? It’s
important to take the time up front to establish clear guidelines for
measuring your site’s success or failure.
Site design : Outsource?
Should you design your site or hand it off to a professional Web
designer or team? The advantage of tackling the job yourself is that
you maintain control and can make instant changes without worrying
about cost. Software programs have point-and-click interfaces that are
designed for non-programmers. Using one of these, you should be able
to have a Web page up and running in a short time. The disadvantage
of self-designing the site is that it may end up lacking in
professionalism or functionality.
For many small businesses, outsourcing site design is the preferred
option. Good designers have the tools and know-how to do a great job,
but Web design services can be costly, and the skills of designers vary
greatly. Be sure to screen the designer’s work and check references.
Another approach is to have a search engine or online directory design,
market and host your Web site.
Find an ISP to host your Web site
If you opt for an outside service, keep these six points in mind as you
shop for an Internet Service Provider (ISP):
1. Does the ISP provide the basic services you may need, such as
e-mail and file transfer protocol (FTP)? If you’re going online solely
to get customer feedback, e-mail alone may be enough. But if you
want to ship reports to satellite offices, your provider will have to offer
FTP.
2. Can it help you set up and maintain a Web page? Some ISP’s
only host, or store, sites. If the provider doesn’t offer design expertise,
it should be able to recommend someone who does.
3. Does it offer the bandwidth, or speed of Internet access, that’s
most appropriate for your business? If you have large groups of
employees who will be using the connection simultaneously, you need
more bandwidth. And, you will need an ISP that has a high-speed
connection to the Internet.
4. How many POP, or remote connection, sites does the ISP have?
If you or your employees travel frequently for business, a nearby POP
provides Internet access at the price of a local phone call.
5. How good is the ISP’s technical support? Your business must
have someone who understands your special needs. If the ISP’s
representatives can’t help you, then it doesn’t matter if it offers
24/7 service.
6. Is the price right? Most hosting services fall within the $20
to $40 per month range. Expect to pay more if you need high
bandwidth and more than basic hosting service (i.e. site design,
updates, URL distribution).
Web site mistakes to avoid
Most small businesses outsource the development and maintenance of
their Web sites, at least at first. But that doesn’t mean you shouldn’t
have clear ideas about how the site should look, feel, and operate. Here
are five pitfalls to avoid as you seek to drive traffic to your site.
❏ Going live too early. It pays big dividends to beta-test your site
before publicizing it.
❏ Lack of clarity. As with any type of marketing, it’s important that
your home page lets the Web surfer know exactly what you do and that
every other element of the site promotes its basic purpose.
❏ Bad navigation. Make sure each page has a navigation bar
allowing browsers to move around without going back to the home
page. (But they should always be able to go to the home page, if they
wish.) Also, prominently list an 800 number, because that’s a familiar
touchstone for many people.
❏ Failure to respond to e-mail. Check e-mail from customers with
7
the same regularity that you check voice mail—certainly at least twice
a day. And, you must respond or people won’t come back.
❏ Poor marketing. With so many sites out there, it’s increasingly
difficult to get noticed. To make it worse, search engines change
their algorithms almost weekly, so you have to keep finding new ways
to make your listing rise to the top by experimenting with links,
banners, and meta tags (keywords or descriptions used by search
engines to categorize your site; see “Use Search Engines to Build
Traffic,” on page 12). ■
Checklist—Where’s Your Online Business Headed?
Setting realistic short-term marketing goals will help you clarify your long-range objectives. This list of questions will help you define the future of
your online business.
I. What are your Internet marketing goals for the next year and the next three to five years in these areas?
❏ Dollar sales ❏ Unit sales ❏ Profits ❏ Market share ❏ Markets to enter ❏ Customer-base expansion
II. What are your six biggest marketing challenges, in order of urgency?
(e.g., consumer trends, technological challenges, customer mix, competition, staffing, margins, media, etc.)
1. 4.
2. 5.
3. 6.
III. What major threats and opportunities will your company face in the next three to five years, in these areas?
❏ Products and services ❏ Customer attitudes and trends ❏ Competition ❏ Changes in technology
❏ Staffing ❏ General business conditions
IV. What new competition do you expect within the next three to five years?
(Consider technological developments and product/service innovations, as well as alliances, mergers and acquisitions.)
V. Which competitors do you expect will decline or disappear within the next year? Three to five years? Why?
1.
2.
3.
VI. What proportion of your online sales a year from now will come from new products or services? %
From new markets? % What about three years from now? %
Sales from new products? % From new markets? %
8
9
Make the Most of E-mail
Chapter 4
E-mail is the single most effective electronic tool for strengthening
customer relationships, reports Forrester Research, a leading
technology research firm.
Forrester estimates that by 2004, more than two-thirds of the
e-mails sent to customers will be geared towards keeping present
customers, rather than acquiring new customers.
As a unique communications and marketing tool, e-mail can be used
to address customer relationship management needs, such as
responding to a request for warranty information or confirming when a
shipment will arrive. Some e-mail responses may be as simple as
directing a customer to a particular page on your Web site, while other
e-mails will lead to a phone conversation between customer and
service rep to answer complicated questions.
1. E-mail provides immediate access, anywhere. E-mail is so
popular because it can be used by anyone, anywhere. Business
travelers can log on at hotels and airport business centers; people
without computers can use free e-mail services like Hotmail
and Yahoo and log on at public libraries, community centers,
and cyber-cafes.
Universal access to e-mail is a double-edged sword. When customers
see that you are available via e-mail, they assume that you are
checking your e-mail frequently. They’ll expect you to respond
promptly. Companies that deliver on their promise to respond to
e-mail queries within an appropriate timeframe are at a distinct
advantage over those that do not. Prompt responses capture a
customer’s attention, loyalty, and orders.
2. Utilize key e-mail functions. Some of the most common Internet
browsers used for e-mail are Netscape, Microsoft’s Outlook and AOL.
E-mail functions are also being added to sales support software
programs that let you screen, file, and organize e-mail. If your
company is small, or if you have relatively few clients, you may not
need much more than the simple database functions embedded in
these e-mail programs to manage your customer contacts. The most
common functions include:
❏ Multiple personalities. Set up different e-mail accounts for specific
brands, locations, or projects; e.g., bbq@hotsauce.com or
sizingquestions@swimsuits.com. This enables you to automatically
forward e-mails to a specific person in your company assigned to
answer them. The specific e-mail addresses can be posted at the
appropriate places on your Web site.
❏ Filters. Create sub-categories in your mailbox so that mail is
automatically deposited in, say, each client’s or project’s slot. You can
also tell clients to flag urgent messages with a certain tagline—such
as “urgent”—and set up a box to receive only those. This enables you
to prioritize your e-mail flow.
❏ In-boxes. Even if you don’t use filters, you can still build archives of
e-mails on particular topics, or projects, or from certain people, by
creating internal in-boxes. These are useful for keeping track of
“conversations” you have with clients, and ensures that you can refer
back to requests—and your responses. If you want to broadcast an
e-mail to everyone who has corresponded with you on a particular
topic, you can use the topic-specific in-box as a de facto e-mail list.
❏ Templates. Called “stationery” by some, this function lets you create
boilerplate messages and simply plug in the recipient’s e-mail address.
This is excellent for answering standard questions, such as driving
directions to your office. However, if you find that certain questions
are asked often, you may want to post the answers on a
frequently-asked-questions (FAQ) list on your Web site.
❏ Auto-respond. This function bounces back a canned answer to a
general e-mail. Most basic browser e-mail functions will only let you
send out an “I’m not here” message that explains why you’re not
going to respond to the e-mail. More sophisticated programs let you
craft different auto-responds that are tailored to the customer’s request
or order history.
❏ Embedded links. Use the “link” function to connect customers with
a Web page within your site or at another site. The e-mail will be sent
in HTML format and the customer can click on the highlighted link to
be transported immediately to that page. This is an easy way to direct
customers to a particular page on your site that they may not have
been able to find.
No matter how you organize the e-mail that flows into your business,
consider what type of response customers are likely to expect. If
they’re making a routine inquiry, such as asking if you carry a certain
brand or item, short and snappy is fine. But if you’re staking your
reputation on customized, high-ticket products or services, be sure to
give a “you’re special” tone to your responses.
3. Make “rich text” e-mail an option. Most Internet users are
accustomed to receiving e-mail in plain text format. But as Web sites
have become more sophisticated, so has e-mail. Options such as
graphics, embedded video and audio that are enacted with a click, and
the ability to respond without going back to the original Web site have
become the cutting-edge in Internet marketing.
10
Enhanced, or “rich,” e-mail is most useful to customers with fast
Internet connections. “Rich” e-mail may be rich text or HTML e-mail. If
many of your customers don’t have fast connections, offer the option of
receiving either a text or rich format e-mail when they initially sign up.
Trip.com, a travel Web site, has a simple, easy-to-understand format
for helping visitors choose which format they prefer—text or rich
e-mail—for its newsletters. Most people are more impressed by an
e-mail message that specifically addresses their needs than with fancy
technology, unless that technology makes their communication with
you significantly easier.
4. Give customers opt in/opt out options. The average U.S. Internet
user received 40 commercial e-mails in 1999, but will be deluged with
1,600 by 2005, according to Jupiter Communications, an e-commerce
analysis firm. People will become increasingly selective about which
e-mails they will read. Response rates will drop dramatically for
e-mails that are considered irrelevant, too pushy, or too intrusive.
When customers find your messages genuinely useful, they eagerly
anticipate, open, and act on your e-mails. But don’t take advantage of
customer goodwill. Even if you already have a database of e-mail
addresses, you want to elicit the permission of those customers
before automatically putting them on your e-mail list. It’s fine to
send out an introductory e-mail, but go no further unless you have a
recipient’s buy-in.
Marketing consultant Seth Godin champions the concept of eliciting a
“yes!” from consumers before signing them up for any follow-up.
“Opt-in” is the term for requesting customers to specifically ask to be
put on your list. “Opt-out” is the term for requiring that customers
specifically instruct you not to use their information for marketing
purposes. Some e-mail marketers adopt the opt-out tactic—that
customers are assumed to be signing up for future e-mails unless they
specifically “opt out.”
The trouble is that many customers won’t scroll far enough down
the e-mail to see how to get off the regular mailing list. If they can’t
figure out how to get off the list, they will automatically delete any
e-mail you send.
A more painstaking, but more productive, tactic is opt-in. Briefly outline
the benefits that customers will get by actively choosing to be on your
e-mail list (e.g., advance notice of sales, first to receive breaking news,
etc.) and then provide a response mechanism for them to put themselves
on your list. Usually that mechanism is to simply hit “reply” and
put in the message line “subscribe.”
Customers are much more likely to say “yes!” if they know exactly
what they are signing up for. ■
11
The key to any site’s success is traffic. No company can advertise,
generate sales, or offer customer service online unless people
visit its Web site. Your site must be promoted so Web users can
find it among the vast number of sites. But this doesn’t mean launching
an expensive ad campaign. One of the great advantages of the Web for
small businesses is that it’s inexpensive to let people know about a
site. E-mail is one of the best ways to get the word out.
E-mail ads invite visitors. Most e-mail programs allow users to create
small files of text that automatically append to the bottom of every
e-mail message they send. For example, at the end of each e-mail
message, you can say something like, “Pike’s Peat, meeting your
landscaping needs since 1962.” The file is called a “signature file,”
and any company with a Web site should include the URL and a brief
description of the site in employees’ signature files. Thus, every e-mail
sent could also include a brief ad like, “Visit our Web site at
www.pikespeat.com to play Land in Clover!”
The key to an effective signature file is to keep it short, ideally four
lines or fewer. Elaborate signature files just take up space and are not
read more than once. A short file usually gets at least a glance every
time, prompting visitors to remember the message.
Adopt direct e-mail, too. Begin by setting up your site to collect e-mail
addresses of visitors. Add a question next to that section asking if they
would like to receive e-mail notifying them of changes to your site and
updates on key information.
Once armed with a list of users willing to receive e-mail, start sending
it to them. Don’t abuse their trust by overwhelming them with press
releases every time a minor change is made to the site, but do create
a regular mailer, perhaps once a month, pointing out a few new
products available on the site or key issues discussed there. The
mailer shouldn’t steal the site’s thunder. It should be more of a teaser
designed to make readers want to visit the site. Keep it very
short and current.
Think rich and informative
“passive content”
Enhanced passive content is information that provides general
customer support for access any time of day or night. Such
content might include:
❏ Company backgrounders
❏ How to contact service reps
❏ Directions to your facility, and business hours
❏ Instructions for using your products
❏ Technical specifications
❏ Schedules for maintenance and upgrades
❏ Product catalogs
Much of this information can be reorganized and placed on your site—
a task that can be accomplished relatively quickly, if you already have
digital files of text, graphics, and other elements. Standard HTML can
be used to make your existing information Web-ready simply and
quickly. Beware, however, that the organization and layout of most
printed pieces are not Web-friendly. If you simply download a brochure,
for example, online visitors may have difficulty navigating through it—
especially if it includes four-color pictures. Break it into simpler graphic
and textual elements and place them separately on your site where
people will look for them.
The “About Us” category is nearly universal on all business sites, so
most people visiting your site will expect to see this internal link. It’s
the place to put basic information about your company—its history,
mission, and short profiles of key managers. Because it’s important to
have a consistent graphic style on your site and in your printed materials,
have a designer simplify the graphics from existing materials so
that they’ll fit the Web format and, more importantly, download quickly.
Define key pages of your Web site
Beyond basic “who’s who” information, what other content should you
post? Start by posting information about items that drive the top 20%
of your sales. This enables customers to find information on the
products they frequently want. Then you can measure requests for
additional information and add Web pages as demand dictates.
Because it costs so little to post each additional page of information,
you should post the routine material that you provide customers.
Here are some examples of content that will enrich your site:
❏ Directions to your physical location. There are three ways to
make it easy for people to find you. First, MapQuest
(www.mapquest.com) offers a free link to an interactive map of your
location on its site. Second, license the map software from
Drive Traffic to Your Site
Chapter 5
12
companies such as MapQuest (www.mapquest.com), Rand McNally
(www.randmcnally.com) and MapPoint (www.mappoint.net). A third
option is to compose and post driving directions to your business from
two or three local landmarks (i.e. airport, downtown), and include a
self-created map.
❏ Company directory. Customers can feel disconnected if their only
option for sending e-mail is to an impersonal address such as
“Webmaster,” or, even worse, “customer support.”
Include a “real person” address for generic customer support, so that
customers don’t feel that they are sending their e-mail into a void.
Better yet, include pop-up e-mail forms with manager profiles so
customers can connect to them directly.
❏ Product and service background information. It may seem logical
to group product descriptions together in one spot, but it’s actually
more helpful to customers to position it throughout your site with
marketing copy.
❏ Assembly directions and replacement parts. Online replicas of
the type of printed material usually packed with a product—e.g.,
warranties, product registration, a form for ordering replacement
parts—are a time and labor saver for your customer service reps
and consumers who have lost or tossed the originals.
Include FAQs within your site
The popular question-and-answer format was one of the first customer
service tools adapted to Web sites. This format is easily understood
and reflects the actual questions that customers ask. This gives
customers a sense that you’re listening to them and responding.
It is easily updated and expanded as your service reps track the
questions that are asked often and then work with your Webmaster
to post the answers. You can leverage the friendly FAQ format even
more by adding links to other parts of your Web site and useful links
to other sites.
When marketing products that elicit many questions, it’s important to
include in-depth product descriptions, e-mail contacts, and your
toll-free number to supplement the generic site-wide “Help” button.
This is an inexpensive way to aid customers and maximize the impact
of your content.
For example, Vitamins.com covers an extensive list of subjects under
its “Help” button that appears at the top of every page. Every product
description is also accompanied by buttons that introduce the site’s
nutritional experts, including pop-up e-mail forms that can be used to
ask them questions. ■
Think of the Internet as the world’s largest library, and search engines
as its card catalog system for the 1 billion documents that are on the
Web. Search engines create their listings by crawling across the Web
to gather information from existing pages.
Research by eMarketer shows that 78% of Web users initially find
sites through search engines. A listing near the top of search engines
such as AltaVista, HotBot, or Infoseek will initially bring more visitors
to your site. Return visits can be reinforced by e-mail, banner ads,
print media and advertising.
Maintaining a top search listing can be challenging. Some pointers:
❏ List with search engines upon launching. As soon as your Web site
is up and running, list its contents with several major search engines
and online directories. For help in registering your site, start with the
DirectoryGuide (www.directoryguide.com), which features more than
400 search engines and directories.
❏ Use meta tags. Search engines look for your site’s meta tags—
special lines of code or keywords that identify what your site is about.
When creating these tags, put the most important information first.
For example, if you sell apparel and footwear to racewalkers, the first
word in your tag should be racewalking, followed by clothing, apparel,
sportswear, and shoes. (For more information on meta tags, visit
www.siteowner.com.)
❏ Put keywords in titles and tags. Pages with keywords in their title
and meta tags receive higher rankings from search engines.
❏ Resubmit regularly. While submitting too often can result in your
site being classified as a spammer, failure to submit at least every
two or three months can keep your site from staying in the search
engine’s index.
❏ Get as many other sites as possible to link to your site. Search
engines use link popularity as part of their ranking criteria.
Use Search Engines to Build Traffic
incremental increase in the number of sales by the cost of the new
technology to determine if the technology is beginning to pay off
(taking into account, of course, other factors that may affect sales,
such as discounted prices, addition of new products, and special
advertising campaigns).
Try a trial run
Consider setting up a customer advisory board to test new site
features, offers, customer service technologies, and changes in your
fulfillment operation.
Customers genuinely appreciate the chance to offer feedback about
what does and does not work with your online efforts. eLoan, a
company that provides online applications for consumer and business
loans, has set a company policy that a human must answer the
customer service phone within six seconds. Its goal is for 90% of its
e-mails to be answered within two hours, and 100% within 24 hours.
Follow-up surveys with eLoan customers about the quality of service
indicate that 95% of customers report that they’d use eLoan again—an
extremely high repeat rate by any standard.
The quality of customer service directly impacts your company’s
reputation. You may want to assign an employee to regularly check
chat sessions, message boards, and listservs outside your Web site
that are frequented by your regular customers to see what kinds of
comments are made about your products and level of service. Also
check out BizRate (www.bizrate.com), Epinions (www.epinions.com),
Better Business Bureau Online (www.bbb.org), any online service
ranking offered by your local chamber of commerce, and even your
state attorney general’s office to be sure that an unhappy customer
hasn’t lodged a complaint. ■
13
While browsing your site, users may buy something. If there is no
sale, how do you know that anyone has stopped by? Web site
operators can collect more information on customers than brick
and mortar store owners can.
Methods of measurement
There are several ways to track visitors. One method is based on number
of “visitors,” which refers to the number of users who visit the site.
Another method is based on the number of “page views.” A person
visiting a site clicks on a page, enlarges a graphic, listens to an audio
recording, or moves within the site.
Each activity makes a request of the site’s host computer to send the
visitor’s computer some electronic information. Those requests are
tracked as “page views.” A page view registers each time a visitor
clicks on part of the site. Companies monitoring visitors and page
views can get a general idea of a site’s traffic and trends by relying on
their own server software or by paying an ISP to track the information.
Some companies have adapted visitor tracking software that offers
even more information. In addition to the number of visitors and page
views, they can determine what browser software visitors are using,
what site the user just came from (so a company can judge how many
visitors come from a link from another site), what modem speed the
visitors are using (so the company can put fewer graphics on the site,
if most visitors are using slow modems, for example), and what type of
Internet access accounts visitors have.
With either type of traffic tracking, the names and e-mail addresses of
visitors usually remain anonymous unless they voluntarily provide it. If
visitors provide that, they might also be willing to provide demographic
information, such as where they live, their income level, and a few
details about their purchasing decisions. Gathering this data online has
become more common. With such information, companies can tailor
their sites to visitors’ demographic profiles. The tracking data can also
become a valuable tool for driving your product research and
marketing decisions.
It’s important to precisely track the results you get from Internet-based
marketing so that you can quickly modify the online tools that aren’t
capturing leads or creating customer loyalty. The simplest formula for
measuring the ROI is to first create a baseline for comparison—the
percent of customers who respond to e-mailed special offers, for
example. Then, track the expenses associated with adding in a
particular customer support technology, such as instant chat. After the
customers have used the new technology for a month, review the
number of sales per site visitor, compared to the number of sales per
site visitor prior to the addition of the technology. Divide the
Track Visitors—and Your ROI
Chapter 6
Menu of ROI Metrics
The payback from a Web site needn’t be solely financial.
Here are nine ways to measure your return on investment:
❏ Number of new accounts
❏Number of repeat purchases
❏Market penetration
❏ Percentage of customers accessing the site
❏Cost per qualified lead
❏Gains in sales and profits
❏Impact on productivity, loyalty, and turnover
❏Time savings
❏Reduced costs (phone, postage, literature,market research, support)
For newcomers to the Web as well as veterans of cyberspace,
here are contacts and references that can help you create and
fine-tune your online marketing programs.
WEB SITES
General/Business
EntreWorld—www.entreworld.org
Kauffman Center for Entrepreneurial Leadership; information on
starting and growing a business
Inc magazine—www.inc.com
Information, products, services, and online tools for starting and
growing your business (marketing is one of five major focuses)
National Federation of Independent Business—www.nfib.org
(800-NFIB-NOW)
Contains a broad array of educational information for small business owners
Service Corps of Retired Executives (SCORE)—www.score.org
(800-634-0245)
Expert problem-solving assistance, ranging from information on
business planning and marketing to its e-mail counseling service
(resources include 1,000 active e-mail counselors, plus 389 counseling
offices across the country)
U.S. Chamber of Commerce/Chamber Biz—
www.chamberbiz.com (888-948-1429)
Network of more than 300 state and local chambers of commerce and
the U.S. Chamber of Commerce
U.S. Small Business Administration (SBA)— www.sba.gov
(800-827-5722)
Guidelines for starting a business; links to research and marketing
information. Provides information on small business loan guarantees.
General/Internet and Marketing
Direct Marketing Association—www.the-dma.org
Oldest and largest trade association for direct, database, and
interactive marketers
eMarketer—www.emarketer.com
Publishes a broad range of e-business and e-commerce statistics
Forrester Research—www.forrester.com
Independent research firm specializing in the Internet and future of
technological change
Internet Learning Tutor—www.superpages.com/ilt
Offers a series of online courses for beginners to advanced users
(sponsored by ASBDC, Internet Education Foundation, SCORE, Verizon,
and the Welfare to Work Partnership)
Verizon SuperPages.com—www.superpages.com
Leading online directory and shopping reference includes Business
Center resource
WebTrends—www.webtrends.com
Provides analysis services of Web logs and Net usage statistics
Workz.com—www.workz.com
Comprehensive resource for small businesses that want to create and
maintain a Web site
CRM Software
CRMCommunity—www.crmcommunity.com
Community-oriented resource for information on evaluating, purchasing,
and implementing customer relationship management technology
and solutions
DestinationCRM—www.destinationcrm.com
Resource for companies that have identified CRM as a key strategy for
creating enhanced customer value across many industries. The site is
associated with CRM Magazine.
E-mail List Management Publications
EzineCentral.com—www.ezinecentral.com
Sells names and e-mail addresses for relevant lists
Ezine-Universe.com—www.ezine-universe.com
Online directory of 8,000 e-mail publications
E-mail List Management Software/Services
List-Universe.com—www.list-universe.com
Resources, directories, tips, and tools for owners of e-mail lists
SparkLIST.com—www.sparklist.com
Provides reliable, easy-to-use e-mail hosting solutions for e-mail lists
Feedback and Tracking Software/Services
BuyStream.com—www.buystream.com
Developer of reporting and analytics software for online retailers and
content providers
14
Resources for Marketing on the Internet
Chapter 7
Informative—www.informative.com
Sells tools that allow e-businesses to interpret and apply customer
feedback
Keynote Systems—www.keynote.com
Provides products that enhance Internet performance for e-businesses
Security and Fraud Prevention
Bureau of Consumer Protection (Federal Trade Commission)—
www.ftc.gov
Internet Fraud Complaint Center (FBI)—www.ifccfbi.gov
TRUSTe—www.truste.org
Non-profit, self-governing board of online retailers
BOOKS
Building Brandwidth: Closing the Sale Online, by Sergio Zyman and
Scott Miller (HarperCollins, 2000, $27)
Complete Guide to Internet Publicity: Creating and Launching
Successful Online Campaigns, by Steve O’Keefe
(John Wiley & Sons, 2002, $34.99)
The Complete Idiot’s Guide to Online Marketing, by Bill Eager and
Cathy McCall (Que, 1999, $16.99)
Connecting to Customers: Strategies and Solutions for Growing
Your Business Online, by Harry Brelsford, Michael Toot, and Karishma
Kiri (Microsoft Press, 2002, $39.99)
CRM at the Speed of Light: Capturing and Keeping Customers in
Internet Real Time, by Paul Greenberg (McGraw-Hill, 2001, $29.99)
CRM Automation, by Barton Goldenberg (Prentice Hall, 2002 & 2003
New Edition, $39.95)
e-Loyalty: How to Keep Your Customers Coming Back to Your Web
Site, by Ellen Reid Smith (Harperbusiness, 2000, $16.99)
Internet Marketing for Dummies, by Frank Catalano and Bud Smith
(Hungry Minds/John Wiley & Sons, 2000, $19.99)
Poor Richard’s E-Mail Publishing, by Chris Pirillo & Peter Kent (Top
Floor Publishing, 1999, $29.95) ■
Verizon Information Services
Verizon Information Services—the world’s leading print
and online directory publisher—distributes nearly 1,200 U.S.
Verizon SuperPages (Yellow Pages) directories and produces
SuperPages.com.
Small and medium-size businesses are served by an “on-the-street”
national sales force of nearly 2,600 professionals providing
customized, targeted advertising. Verizon offers advertising bundles
that include placement in both the print and online directories.
Products include:
• SuperPages print advertising
• Up to 15-page Web site built by SuperPages.com, including a URL
• Extra text in print SuperPages to promote your Web or e-mail address
• Option of cities/county where the Web site will appear on
SuperPages.com
Plus: print and online coupons, e-store solutions, banner ads,and more.
SuperPages.com, with more than 9 million visitors monthly, offers your
customers these unique features that promote your business:
• SuperTopics provide consumer-oriented tips and links to merchants
offering related goods and services.
• City Pages features local shopping guides for numerous U.S. cities.
• MerchantMatch links interested buyers to qualified merchants,
creating a buyer/seller-matching network.
• Business Center highlights business topics and provides
management tools and content.
For more information, visit www.verizon.superpages.com.
SCORE “Counselors to America’s Small Business”
SCORE is a nonprofit, public service organization dedicated to helping
entrepreneurs succeed as small business owners. For free advice from
SCORE, get e-mail counseling at www.score.org, or call 800-634-0245
to find a SCORE office near you.
More than 10,500 SCORE business counselors volunteer their time
and expertise to provide free and confidential small-business advice
and mentoring. SCORE is a resource partner with the
U.S. Small Business Administration.
SCORE provides advice and counseling on topics such as starting a
business, business planning, management, and marketing. SCORE
counselors are active and retired business owners and executives,
with experience in a wide variety of business disciplines.
15

Resources for Marketing on the Internet
Editor: Brad Ketchum, Jr.
Designer: Conceptual, Inc.
Published by Business Innovator Group Resources
(BIGR), a division of Gruner + Jahr USA, publisher of Inc
magazine. Copyright © 2002 by Gruner + Jahr USA,
Boston, MA. All rights reserved.
No part of this book may be used or reproduced in any
manner whatsoever without written permission from
the publisher (contact: BIGR/Inc magazine,
38 Commercial Wharf, Boston, MA 02110).
This publication is designed to provide accurate and
authoritative information in regard to the subject matter
covered. However, the publisher is not engaged in rendering
legal, accounting, or other professional advice. If
legal advice or other expert assistance is required, the
services of a competent professional should be sought.
Sponsored by Verizon Information Services
(www.verizon.superpages.com),
in cooperation with SCORE (www.score.org).
The material in this workbook is based on work
supported by the U.S. Small Business Administration
(SBA) under cooperative agreement number
SBAHQ-02-S-0001. Any opinions, findings, and
conclusions or recommendations expressed in this
publication are those of the author(s) and do not
necessarily reflect the views of the SBA.

Posted in Bussiness | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.