Kamis, 10 April 2014

Cara Buat Web Sederhana Dengan Mudah Dari PHP.com 1. Script home.php
WELCOME TO MY WEBSITE
BG NAGA

2. Script formpetugas.php
"SELAMAT DATANG DI WEBSITE SEDERHANA YOANNES
SINAGA NPM: 12320109"
FORM DATA PETUGAS
Nip
Nama
Jenkel
Alamat
Phone
3. Script form editpetugas.php Edit Data


FORM EDIT DATA PETUGAS
Nip
Nama
Jenkel
Alamat
Phone
 

4. Script listpetugas.php Edit Data


FORM EDIT DATA PETUGAS
Nip
Nama
Jenkel
Alamat
Phone
 

5. Script deletepetugas.php Kembali"; ?> 6. Script entripetugas.php Kembali"; ?> 7. Script koneksi2.php 8. Script updatepetugas.php Kembali"; ?> Cara nyimpan program: data c > xampp > htdoc > new folder Setelah di buat programnya: Browser ke Mozila Localhost/nama folder didata c, Selamat Mencoba ya temanku:”senang berbagi ilmu”


                          Cara Buat Web Sederhana Dengan Mudah
                                                        Dari PHP.com
 
     
1.       Script  home.php
<style type="text/css">
body p {
                text-align: center;
}
body p {
                font-family: "Courier New", Courier, monospace;
}
body p {
                font-weight: bold;
}
body p {
                font-size: 36px;
}
body p {
                color: #03F;
}
</style>
<body background="Foto0132.jpg">
<form name="form1" method="post" action="">
  <p>WELCOME TO MY WEBSITE</p>
  <p>BG NAGA</p>
  <p><a href="listpetugas.php"><img src="hanura.png" width="200" height="200" hspace="5" vspace="4" border="10"></a></p>
</form>
</body>    













2.       Script formpetugas.php

<style type="text/css">
<!--
.style6 {color: #0000FF; font-family: "Courier New", Courier, monospace; font-weight: bold; font-size: 24px; }
.style7 {font-size: 24px}
.style8 {color: #0000FF; font-size: xx-large; font-family: "Courier New", Courier, monospace; font-weight: bold; }
-->
</style>
<form name="form1" method="post" action="entripetugas.php">
  <p align="center"><span class="style8">&quot;SELAMAT DATANG DI WEBSITE SEDERHANA YOANNES </span></p>
  <p align="center"><span class="style8"> SINAGA NPM: 12320109&quot;</span></p>
  <table width="442" border="0" align="center" bgcolor="#00FF33">
    <tr>
      <td colspan="2" align="center"><div align="center" class="style6">FORM DATA PETUGAS </div></td>
    </tr>
    <tr>
      <td width="213"><span class="style6">Nip</span></td>
      <td width="213"><span class="style6">
        <label>
        <input name="nip" type="text" id="nip">
        </label>
      </span></td>
    </tr>
    <tr>
      <td><span class="style6">Nama</span></td>
      <td><span class="style6">
        <label>
        <input name="nama" type="text" id="nama">
        </label>
      </span></td>
    </tr>
    <tr>
      <td><span class="style6">Jenkel</span></td>
      <td><span class="style6">
        <label>
        <input name="jk" type="text" id="jk">
        </label>
      </span></td>
    </tr>
    <tr>
      <td><span class="style6">Alamat</span></td>
      <td><span class="style6">
        <label>
        <input name="almt" type="text" id="almt">
        </label>
      </span></td>
    </tr>
    <tr>
      <td><span class="style6">Phone</span></td>
      <td><span class="style6">
        <label>
        <input name="telp" type="text" id="telp">
        </label>
      </span></td>
    </tr>
    <tr>
      <td><span class="style6">
        <label>
        <input type="submit" name="Submit" value="Simpan">
        <input type="reset" name="Submit2" value="Batal">
        </label>
      </span></td>
      <td><span class="style7"></span></td>
    </tr>
  </table>
</form>



3.       Script form editpetugas.php
<?php
$sambung = mysql_connect("localhost","root","") or die ("gagal konek ke server.");
mysql_select_db("coba3") or die ("gagal membuka database.");
$Nip= $_GET['Nip'];
$query= "select*from petugas where Nip='$Nip'";
$result= mysql_query($query,$sambung) or die ("gagal melakukan query");
$buff = mysql_fetch_array($result);
mysql_close($sambung);
?>
<html>
<head><title>Edit Data</title>
<style type="text/css">
<!--
.style1 {
                font-family: "Courier New", Courier, monospace;
                font-size: 24;
                font-weight: bold;
                font-style: italic;
}
.style2 {
                font-family: "Courier New", Courier, monospace;
                font-weight: bold;
                font-size: 24px;
                color: #0000FF;
}
.style4 {
                font-family: "Courier New", Courier, monospace;
                font-size: 24px;
                font-weight: bold;
                font-style: italic;
                color: #0000FF;
}
-->
</style>
</head>
<body background="1753566636renderkamuis5.png">
<form name="form1" method="post" action="updatepetugas.php">
  <p align="center" class="style1">&nbsp;</p>
  <p align="center" class="style1">&nbsp;</p>
  <p align="center" class="style1 style2">FORM EDIT DATA PETUGAS</p>
  <table width="477" border="0" align="center">
    <tr>
      <td width="230" class="style4">Nip</td>
      <td width="231" class="style4"><label>
      <input name="nip" type="text" id="nip" value="<?php echo $buff['Nip']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Nama</td>
      <td class="style4"><label>
        <input name="nama" type="text" id="nama" value="<?php echo $buff['Nama']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Jenkel</td>
      <td class="style4"><label>
        <input name="jk" type="text" id="jk" value="<?php echo $buff['Jenkel']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Alamat</td>
      <td class="style4"><label>
        <input name="almt" type="text" id="almt" value="<?php echo $buff['Alamat']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Phone</td>
      <td class="style4"><label>
        <input name="telp" type="text" id="telp" value="<?php echo $buff['Phone']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4"><label>
        <input type="submit" name="Submit" value="Simpan">
        <input type="reset" name="Submit2" value="Batal">
      </label></td>
      <td class="style4">&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>





4.       Script listpetugas.php

<?php
$sambung = mysql_connect("localhost","root","") or die ("gagal konek ke server.");
mysql_select_db("coba3") or die ("gagal membuka database.");
$Nip= $_GET['Nip'];
$query= "select*from petugas where Nip='$Nip'";
$result= mysql_query($query,$sambung) or die ("gagal melakukan query");
$buff = mysql_fetch_array($result);
mysql_close($sambung);
?>
<html>
<head><title>Edit Data</title>
<style type="text/css">
<!--
.style1 {
                font-family: "Courier New", Courier, monospace;
                font-size: 24;
                font-weight: bold;
                font-style: italic;
}
.style2 {
                font-family: "Courier New", Courier, monospace;
                font-weight: bold;
                font-size: 24px;
                color: #0000FF;
}
.style4 {
                font-family: "Courier New", Courier, monospace;
                font-size: 24px;
                font-weight: bold;
                font-style: italic;
                color: #0000FF;
}
-->
</style>
</head>
<body background="1753566636renderkamuis5.png">
<form name="form1" method="post" action="updatepetugas.php">
  <p align="center" class="style1">&nbsp;</p>
  <p align="center" class="style1">&nbsp;</p>
  <p align="center" class="style1 style2">FORM EDIT DATA PETUGAS</p>
  <table width="477" border="0" align="center">
    <tr>
      <td width="230" class="style4">Nip</td>
      <td width="231" class="style4"><label>
      <input name="nip" type="text" id="nip" value="<?php echo $buff['Nip']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Nama</td>
      <td class="style4"><label>
        <input name="nama" type="text" id="nama" value="<?php echo $buff['Nama']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Jenkel</td>
      <td class="style4"><label>
        <input name="jk" type="text" id="jk" value="<?php echo $buff['Jenkel']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Alamat</td>
      <td class="style4"><label>
        <input name="almt" type="text" id="almt" value="<?php echo $buff['Alamat']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4">Phone</td>
      <td class="style4"><label>
        <input name="telp" type="text" id="telp" value="<?php echo $buff['Phone']; ?>">
      </label></td>
    </tr>
    <tr>
      <td class="style4"><label>
        <input type="submit" name="Submit" value="Simpan">
        <input type="reset" name="Submit2" value="Batal">
      </label></td>
      <td class="style4">&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>







5.       Script deletepetugas.php

<?php
include("koneksi2.php");
mysql_query("delete from petugas where Nip='$_GET[Nip]'");
echo"Data Telah dihapus<br>
<a href=\"listpetugas.php\">Kembali</a>";
?>

6.       Script entripetugas.php

<?php
include("koneksi2.php");
error_reporting(0);
$Nip=$_POST['nip'];
$Nama=$_POST['nama'];
$Jenkel=$_POST['jk'];
$Alamat=$_POST['almt'];
$Phone=$_POST['telp'];

$query = mysql_query("insert into petugas values('$Nip','$Nama','$Jenkel','$Alamat','$Phone')");
echo "Data Telah Tersimpan<br><a href=\"formpetugas.php\">Kembali</a>";
?>


7.       Script koneksi2.php

<?php
$host="localhost";
$user="root";
$pass="";
$db="coba3";
$sambung=mysql_connect($host,$user,$pass);
mysql_select_db($db,$sambung);
?>


8.       Script  updatepetugas.php

<?php
include("koneksi2.php");
$Nip=$_POST['nip'];
$Nama=$_POST['nama'];
$Jenkel=$_POST['jk'];
$Alamat=$_POST['almt'];
$Phone=$_POST['telp'];

$query= mysql_query("update petugas set NAMA='$Nama',JENKEL='$Jenkel',ALAMAT='$Alamat',PHONE='$Phone' where Nip='$Nip'");
echo "Data Telah Diupdate<br><a href=\"listpetugas.php\">Kembali</a>";
?>


Cara nyimpan program: data c > xampp > htdoc > new folder
Setelah di buat programnya: Browser ke Mozila
Localhost/nama folder didata c,

Selamat Mencoba ya temanku:”senang berbagi ilmu”