Minggu, 28 Maret 2010

LOGIN MAKE PROGRAM PHP


Login PHP
Masih Ingat dengan cara masuk Facebook. Pasti dia minta cara dengan masukin nama user dan password. Kepikiran gak gimana cara buat program itu. Nah ini salah satu aplikasinya, pake php lo lumayan sulit sih tapi mungkin mudah bagi kamu. Jadi coba pelajari aja.


<html>
<head>
<title>Login here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
input {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
height: 20px;
}
-->
</style>
</head>
<body>
<div align="center">
<form action="periksa.php" method="post" name="login">
<table width="286" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr bgcolor="blue">
<td height="19" colspan="2" align="center" valign="middle">
<font color="#FFFFFF">LOGIN </font></td>
</tr>
<tr>
<td width="106" height="27">&nbsp;</td>
<td width="180">&nbsp;</td>
</tr>
<tr>
<td height="18" align="right" valign="middle">Username :&nbsp;</td>
<td valign="middle">
<input name="username" type="text" id="username" size="20"></td>
</tr>
<tr>
<td height="18" align="right" valign="middle">Password :&nbsp;</td>
<td valign="middle">
<input name="password" type="password" id="password" size="20"></td>
</tr>
<tr>
<td height="19">&nbsp;</td>
<td></td>
</tr>
<tr>
<td height="18" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="middle">
<input name="login" type="submit" id="login" value=" Login "></td>
</tr>
<tr>
<td height="28">&nbsp;</td>
<td></td>
</tr>
<tr bgcolor="blue">
<td height="18" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
</form>
</div>
</body>
</html>

Pemeriksaan Login
<?php
session_start();
#**************** koneksi ke mysql *****************#
$host = "database";
$user = "bobby";
$pass = "310787";
$dbname = "db_bobby";
$conn = mysql_connect($host,$user,$pass);
if($conn) {
//select database
$sele = mysql_select_db($dbname);
if(!$sele) {
echo mysql_error();
}
}
#jika ditekan tombol login
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = mysql_query("SELECT * FROM user WHERE username='$username' &&
password='$password'");
$num = mysql_num_rows($sql);
if($num==1) {
// login benar //
$_SESSION['user'] = $username;
$_SESSION['passwd'] = $password;
?><script language="JavaScript">alert('Anda berhasil login');
document.location='berhasil.php'</script><?
} else {
// jika login salah //
?><script language="JavaScript">alert('Username atau password Anda
salah'); document.location='login.php'</script><?
}
}
?>
Login berhasil dan halaman logout
<?
session_start();
//periksa apakah user telah login atau memiliki session
if(!isset($_SESSION[‘user’]) || !isset($_SESSION[‘passwd’])) {
?><script language=’javascript’>alert(‘Anda belum login. Please login dulu’);
document.location=’login.php’</script><?
} else {
?>
<html>
<head>
<title>Berhasil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="746" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="746" height="23" align="center" valign="top"><font face="Verdana, Arial,
Helvetica, sans-serif">Selamat
Datang <? echo $_SESSION['user'] ?>&nbsp;<a
href="logout.php"><strong>LOGOUT</strong></a></font></td>
</tr>
<tr>
<td height="88">&nbsp;</td>
</tr>
<tr align="center" valign="middle">
<td height="33"><font color="#FF0000" size="5" face="Arial, Helvetica, sans-serif">ANDA
BERHASIL LOGIN !!</font></td>
</tr>
<tr>
<td height="62">&nbsp;</td>
</tr>
</table>
</body>
</html>

Sumber : Achmad Solichin


Minggu, 14 Maret 2010

PASSING ARGUMEN PHP

PASSING ARGUMEN BY VALUE AND BY REFERENCE

Passing by  value.
Semua nilai yang di-pass masuk atau keluar dari fungsi  adalah passing by value, ini berarti PHP membuat  kopian dari nilai original dan nilai kopian itulah yang kita akses  dan kita manipulasi, bukan nilai originalnya. Gak abdol kalo gak ada contonya : 
Nih dia 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en" lang="en">
head>
<title>value </title>
</head>
<body>
<?phpfunction jumlah($nilai) 

{$nilai++;
}$input=5;

jumlah($input);
echo $input;
?>
</body>
</html>


Passing by Reference
Passing by reference  memberikan nilai aslinya untuk diakses dan dimanipulasi, dengan  contoh yang sama seperti diatas, kita akan modifikasi menjadi  mekanisme passing by reference.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en" lang="en">
head>
<title>reference </title>
</head>
<body>
<?php

function jumlah(&$nilai)  {
$nilai++;
}
$input=5;
jumlah($input);
echo $input;
?>
</body>
</html>

Sabtu, 06 Maret 2010

Web Aplikasi Kalkulator

KALKULATOR SANGAT SEDERHANA

Namanya aja sederhana apalagi sangat, jadi mudah banget. Kamu dapat mempelajarinya dengan mudah. Cukup mengetahui syntac bagaimanan membuat text box dulu baru ke rumus kalkulator. Udah cukup kali basa-basinya biar gak penasaran lihat aja langsung di bawah.




Nah ini syntack kode:
Gak panjang kok

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>KALKULATOR</title>
<script language="javascript" type="text/javascript">
<!--
var flag = false;
function isi(num) {
if (flag) calc.b.value += num;
else calc.a.value += num;
}
function tambah()
{
calc.opr.value = ' + '
flag = true;
calc.b.focus()
}
function kurang()
{
calc.opr.value = ' - '
flag = true;
calc.b.focus()
}
function kali()
{
calc.opr.value = ' * '
flag = true;
calc.b.focus()
}
function bagi()
{

calc.opr.value = ' / '
flag = true;
calc.b.focus()
}
//-->
</script>
</head>
<form name="Kalkulator">
<tr>
<td>
<input type="text"name="bil1"size="4" />
<select name="opr" onchange="setSelected(this);">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text"name="bil2"size="4" />
<input type="button" name="hasil" value="=" onclick="Kalkulator.hasilnya.value=eval(Kalkulator.bil1.value+Kalkulator.opr.value+Kalkulator.bil2.value)" />
<input type="text"name="hasilnya"size="6" />
<br/>
</td>
</tr>
</table>
</form>
</body>
</html>

Senin, 01 Maret 2010

WEB DESIGN SEDERHANA

LAYOUT SEDERHANA




Ini kerangka layout design yang sederhana LOOOO, pelajari Ya karena ini awal kita bisa buat layout yang jauh lebih keren dengan gambar dan tulisan maupun link di dalamnya..!!
Ini Programnya:




<!DOCTYPE html




PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head>


<title>Desain Layout Sederhana</title>


<link rel="stylesheet" href="mystyle.css" type="text/css" />


</head>


<body>


<div id="wrapper">


<div id="header">


Header


</div>


<div id="inner">


<div id="sidebar">


Sidebar


</div>


<div id="content">


Top


</div>






<div id="gooter">


Content


</div>


<div id="right">


Right


</div>






</div>


<div id="footer">


Footer


</div>


</div>


</body>


</html>

Kode Css:
#wrapper {



margin: auto;


width: 750px;


border: 1px solid red;


}


#header {


height: 80px;


border: 1px solid blue;


}


#inner {


float: left;


margin: 5px 0;


border: 1px solid black;


}










#sidebar {


float: left;


margin-right: 20px;


width: 180px;


height: 330px;


border: 1px solid red;


}


#content {


float: left;


width: 543px;


height: 100px;


border: 1px solid green;


}


#gooter {


float: left;


width: 320px;


height: 230px;


border: 1px solid pink;


}


#right {


float:right;


width:200px;


height:150px;


border:1px solid orange;


}










#footer {


clear: both;


height: 50px;


border: 1px solid blue;


}

Nah Ini baru Kerangka Yang udah berbentuk Design denga Gambar & tulisan, Lucu Yaaa???
Coment ya ke aku!!!


INi programnya:
<!DOCTYPE html



PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">






<head>


<title>Desain Web Football</title>


<link rel="stylesheet" href="style.css" type="text/css" />






</head>






<body>


<div id="wrapper">


<div id="header">


<div id = "box1">


<img src="Persema.gif">


</div>


<div id = "box7">


<img src="teksboxatas1.GIF">


</div>


<div id = "box5">


</div>


<div id = "box6"><font color="black"> About :


</div>


<div id = "box2">


<a href="link.html"> <font color="black">Contact</a></p>


</div>


<div id = "box3">


<a href="link.html"><font color="black"> Rss</a></p>


</div>


<div id = "box4">


<a href="link.html"><font color="black"> Sitemap</a></p>


</div>


</div>






<div id="inner">


<div id="sidebar">


<div id="leftmenu">


<ul>


<li><a href="#">Home</a></li>


<li><a href="#">News and Media</a></li>


<li><a href="#">Tutorials</a></li>


<li><a href="#">Tips & Tricks</a></li>


<li><a href="#">Downloads</a></li>


</ul>


</div>


</div>


<div id="top">


<div id = "box8">


<img src="persema1.jpg">


</div>


<div id = "box9">


<img src="AremaMalang1.jpg">


</div>


</div>










<div id="content">


<b>Persema Bangkit<br/></b>


<br/>


Persema mulai berbenah dengan mulai pelatihan menjelang derby melawan Arema. Kemenangan akan menjadi motivasi mereka meraih posisi papan atas.


Persema sendiri tidak diperkuat dua pemain asing dari korea park chul hyung dan back seme petrick<br/>






</div>


<div id="right">


<b>Jadwal Tim :</b>


<ul>


<li>Latihan Pemusatan di Gajayana </li>


<li>Gladi Bersih Formasi</li>


<li>Hari Pertandingan</li>


</div>


</div>


<div id="footer">


<h3 align="center"><b>2010 PERSEMA MALANG, Indonesia Super League </b></h3>


</div>


</div>


</body>


</html>

Kode Cssnya:
#wrapper {


margin: auto;

width: 1000px;

background: blue;



border: 1px solid blue;

}

#header {

height: 100px;

background: blue;

border: 1px solid blue;

}

#inner {

float: left;

margin: 3px 0;

border: 1px solid blue;

}

#sidebar {

float: left;

margin-right: 5px;

width: 175px;

height: 357px;

background: #blue;

border: 1px solid white;

}



#top {

float: left;

width: 813px;

height: 135px;

background: #FFFFCC;

border: 1px solid white;

}



#content {

float: left;

margin-right: 5px;

width: 450px;

height: 220px;

background: #FFFFCC;

border: 1px solid white;

}



#right {

float: right;

width: 357px;

height: 165px;

background: #CCFF99;

border: 1px solid white;

}



#footer {

clear:both;

height: 50px;

background: red;

border: 1px solid white;

}



#leftmenu ul {

width: 175px;

list-style-type:none;

padding:0; margin:0;

}

#leftmenu a:link, #leftmenu a:visited, #leftmenu a:active {

padding-left: 15px;

text-decoration: none;

}

#leftmenu a {

padding: 5px 0px 5px 15px; display: block;

background: red no-repeat left center;

margin: 0px 0px 1px; color: black;

}

#leftmenu a:hover {

background: black no-repeat left center; color: black

}



#box1 {

float: left;

margin-right:10px;

width: 91px;

height: 98px;

background: #FFFFFF;

border: 1px solid white;

}



#box2{

float: right;

margin-right: 20px;

margin-top: 7px;

width: 60px;

height: 20px;

background: red;

border: 1px solid #blue;

}



#box3{

float: right;

margin-right: 10px;

margin-top: 7px;

width: 35px;

height: 20px;

background: red;

border: 1px solid #blue;

}



#box4{

float: right;

margin-right: 20px;

margin-top: 7px;

width: 48px;

height: 20px;

background: red;

border: 1px solid #blue;

}



#box5{

float: right;

margin-right: 15px;

margin-top: 7px;

width: 100px;

height: 20px;

background: #FFFFFF;

border: 1px solid #99CC00;

}

#box6{

float: right;

margin-right: 5px;

margin-top: 7px;

width: 50px;

height: 20px;

background: red;

border: 1px solid #blue;

}



#box7 {

float: left;

margin-right: 5px;

margin-top: 2px;

width: 490px;

height: 85px;

background: #FFFFCC;

border: 1px solid #FFFFCC;

}

#box8 {

float: left;

margin-right: 3px;

margin-top: 5px;

width: 406px;

height: 110px;

background: #FFFFCC;

border: 1px solid #FFFFCC;

}

#box9 {

float: left;

margin-right: 0px;

margin-top: 5px;

width: 400px;

height: 110px;

background: #FFFFCC;

border: 1px solid #FFFFCC;

}