isset dengan PHP_SELF

erick · Oct 25, 2012
mas saya mau tanya,saya punya sourcode seperti ini tp tdk terexsekusi..
<html>
<head>
<title>hitung</title>
</head>
<body>
	<? if (!isset($hitung))
	
	{?>
	<form method="get" action="<? $PHP_SELF; ?>">
		<input type="text" name="bilangan1" size="20">+
		<input type="text" name="bilangan2" size="20">
		<input type="submit" value="Hitung" name="hitung">
	</form>
	<?
		}
		else
		{
			$hasil=$bilangan1+$bilangan2;
			echo "$bilangan1"."+"."$bilangan2";
			echo "=".$hasil."<br>";
		};
	?>
	</body>
</html>

Lihat semua 1 jawaban

Silahkan login untuk menjawab!

select 3 kolom

Robert James M · Oct 24, 2012
mas aku mau tanya, bagaimana cara membuat hasil select itu pas muncul menjadi 3 kolom dan bukan terus kebawah, ini script yang sudah aku buat, terima kasih
<!DOCTYPE html>
<html lang="en">
<head>
  	<title>select 3 kolom</title>
  	<meta charset="utf-8">
    <meta name="description" content="Your description">
    <meta name="keywords" content="Your keywords">
    <meta name="author" content="Your name">
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery-1.7.1.min.js"></script>
    <script src="js/superfish.js"></script>
    <script src="js/jquery.easing.1.3.js"></script>
    <script src="js/tms-0.4.1.js"></script>
    <script src="js/slider.js"></script>
<!--[if lt IE 8]>
   <div style=' clear: both; text-align:center; position: relative;'>
     <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode">
       <img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." />
    </a>
  </div>
<![endif]-->
<!--[if lt IE 9]>
	<script src="js/html5.js"></script>
	<link rel="stylesheet" href="css/ie.css"> 
<![endif]-->
</head>
<body>
<div class="main-indents">
    <div class="main">
        <!-- Header -->
        <header>
            <h1 class="logo">&nbsp;</h1>
            <nav>
                <ul class="sf-menu">
                    <li class="current"><a href="index.php">Home</a></li>
                    <li><a href="login.php">Login</a></li>
                    <li><a href="form_user.php">Daftar</a></li>
					<li><a href="form_iklan.php">Iklan</a></li>
                    <li><a href="search.php">Search</a></li>
                </ul>
            </nav>
            <div class="clear"></div>
        </header>
        <!-- Slider -->
        <div class="">
            <ul class="items">
                <li>
                  <img src="images/slide-3.jpg" alt="" width="960" />
            </ul>
      </div>
        <!-- Content -->
        <section id="content"><div class="ic"></div>
            <div class="container_12">
           	  <article class="a1"></article>
                <article class="content-box">
                	<h3 class="hp-1">Iklan</h3>
					
<?php

  mysql_connect   ("localhost", "root", "");
  mysql_select_db ("");
  
   if(isset($txtcari))
	{
	   $myquery="select Tipe, Nama_produk, Nama_user, Email, Tlp, Harga from iklan where Id_iklan='$txtcari' or Tipe LIKE '%$txtcari%'";
	}
	else
	{
	   $myquery="select Id_iklan, Tipe, Nama_produk, Nama_user, Email, Tlp, Harga from iklan";
	}
		$daftarsiswa=mysql_query($myquery) or die (mysql_error());
		
	while($hasil=mysql_fetch_object($daftarsiswa))
	{

              ?>
  
  
  
 

                    <div class="wrapper">
                    	<div class="col-1">
                        	<figure class="img-box"></figure>
                            <h5><span>Jenis Iklan :</span> <?php echo $hasil->Tipe;?></h5>
                            <p>	
								<span>Id iklan 	:</span><?php echo $hasil->Id_iklan;?><br>
                            	<span>Produk 	:</span><?php echo $hasil->Nama_produk;?><br>
								<span>Oleh 		:</span><?php echo $hasil->Nama_user;?><br>
								<span>Email		:</span><?php echo $hasil->Email;?><br>
								<span>Tlp 		:</span><?php echo $hasil->Tlp;?><br>
								<span>Harga 	:</span><?php echo $hasil->Harga;?>
                            </p>
                        </div>						
                    </div>
					<?
	}
?>
                </article>
            </div>
        </section>
        <!-- Footer -->
        <footer>
            
		<ul class="social-list">
            	<li><a href="#"><img src="images/soc-icon-1.png" alt=""></a></li>
                <li><a href="#"><img src="images/soc-icon-2.png" alt=""></a></li>
                <li><a href="#"><img src="images/soc-icon-3.png" alt=""></a></li>
            </ul>
        </footer>
    </div>
</div>
</body>
</html>

Lihat semua 1 jawaban

Silahkan login untuk menjawab!

Script Ongkir

Dimas · Oct 24, 2012
Newbi mau numpang tanya nih gan,dan mohon panduan tuk script php nya,
Misalkan saya punya data pengiriman seperti ini :
Tujuan : Belawan - Medan
KGpertama = 20.000 / KGP
KGselanjutnya = 15.000 / KGs
BT-KGpertama = 10.000 / btKGp
BT-KGselanjutnya = 5.000 / btKGs
* ( KG = Kilogram / BT = Biaya Terusan(dari kota Medan di lanjutkan ke belawan )

Secara manual cara hitung begini gan :
( KGp + KGs ) + ( bpKGp + btKGs )

contoh nya gini gan :
* ( BB = Berat Barang )
BB = 1KG
( 20.000 + 10.000 )

BB = 3KG
((1kg x 20.000)+(2kg x 15.000))+((1kg x 10.000)+(2kg x 5.000))

Mohon panduan nya gan, terimakasih

Lihat semua 2 jawaban

Silahkan login untuk menjawab!
1.Pertama buat koneksi.php
<?php
$host = "localhost";
$username = "root";
$password = "123";
$database = db_hrd;
$conn = mysql_connect($host,$username,$password);
if (!$conn) die ("Gagal Melakukan Koneksi");
mysql_select_db($database,$conn) or die ("Database Tidak Diketemukan di Server");
?>
2.lalu buat index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Absen</title>
<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript" src="jquery.ui.datepicker-id.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.11.custom.css" />
   <script type="text/javascript">
 $(document).ready(function() {
 $("#tanggal1").datepicker({
   dateFormat : "dd-mm-yy",
   changeMonth: true,
   changeYear: true,
   yearRange: "-100:+0",
   showon: "button",
   buttonText: "menampilkan date picker",
   buttonImage: "calendar.gif",
   buttonImageonly: true
   });
   });
   </script>
</head>
<body>
<form method="post" action="cari.php">
<? $tangg=date('d-m-Y'); ?>
Tanggal Masuk :<input value="<? echo $tangg ?>" id="tanggal1"name="tanggal1"/>
<table border="1">
<th colspan="3">Kriteria Pencarian</th>
<tr>
<td><input type="radio" value="nama" name="search" checked="checked"/>Nama</td>
<td><input type="radio" value="dep" name="search" />Dep</td>
<td><input type="radio" value="nip" name="search" />NIP</td>
<td><input type="text" name="cari" value="Cari.." onclick="this.value=''" /></td>
<td><input type="submit" value="Tampilkan"/></td>
</tr>
</table>
</form><hr />
</body>
</html>
2.lalu buat cari.php
<?
include"koneksi.php";
$kri=$_POST['search'];
$t=$_POST['tanggal1'];
$tgl= substr($t,-4,4) . substr($t,2,3) .'-'. substr($t,0,2);
$tanggal=substr($t,0,2);
$bulan=substr($t,3,2);
$tahun=substr($t,-4,4);
$txt=$_POST['cari'];
if($kri=="nama"){
	include"index.php";
	?>
    <table border="1" cellspacing="0" cellpadding="0" vspace="0">
    <tr>
    <td>NIP</td>
    <td>Nama</td>
    <td>Departement</td>
    <td>Jenis Kelamin&nbsp;</td>
    <td>Kehadiran&nbsp;</td>
    <td>Jenis&nbsp;</td>
    <td>Keterangan&nbsp;</td>
    </tr>
    <?
    $sql=mysql_query("SELECT * FROM tabel_karyawan WHERE Nama LIKE '%$txt%'")or die(mysql_error());
	if(mysql_num_rows($sql)==0){
	?><script language="javascript">alert("Data Tidak Ada");</script>
	<meta http-equiv="refresh" content="0;url=index.php"><?
	}else{
	while($res=mysql_fetch_array($sql)){
		$nik=$res['NIK'];
		$abs=mysql_query("SELECT * FROM view_absesn WHERE tanggal=$tgl")or die(mysql_error());
		$sul=mysql_fetch_array($abs);
		$nk=mysql_query("select NIK from tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
		$nkh=mysql_fetch_array($nk);
		$absen=$nkh['absen'];
	?>
    <tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
    <td>&nbsp;<? echo $res['NIP']; ?></td>
    <td><? echo $res['Nama']; ?></td>
    <td><? echo $res['dept']; ?></td>
    <td align="center"><? echo $res['jk']; ?></td>
    <td align="center">&radic;</td>
    <td align="center">-</td>
    <td align="center">-</td>
   <form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=250');" id="dialog-link" class="ui-state-default ui-corner-all">
   <input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
   <input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
   <input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
   <input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
   <input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
    <input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
    <input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
    <input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
    <td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
    </form>
    </tr>
    <? } ?>
    </table>
	<? }
}elseif($kri=="dep"){
	include"index.php";
	?>
    <table border="1" cellspacing="0" cellpadding="0" vspace="0">
    <tr>
    <td>NIP</td>
    <td>Nama</td>
    <td>Departement</td>
    <td>Jenis Kelamin&nbsp;</td>
    <td>Kehadiran&nbsp;</td>
    <td>Jenis&nbsp;</td>
    <td>Keterangan&nbsp;</td>
    </tr>
    <?
    $sql=mysql_query("SELECT * FROM tabel_karyawan WHERE dept LIKE '$txt%'")or die(mysql_error());
	if(mysql_num_rows($sql)==0){
		?><script language="javascript">alert("Data Tidak Ada");</script>
	<meta http-equiv="refresh" content="0;url=index.php"><?
	}else{
	while($res=mysql_fetch_array($sql)){
		$nik=$res['NIK'];
		$abs=mysql_query("SELECT * FROM tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
		$sul=mysql_fetch_array($abs);
		$nk=mysql_query("select NIK from tabel_absesn WHERE tanggal=$tgl")or die(mysql_error());
		$nkh=mysql_fetch_array($nk);
		$absen=$nkh['absen'];
	?>
    <tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
    <td><? echo $res['NIP']; ?></td>
    <td><? echo $res['Nama']; ?></td>
    <td><? echo $res['dept']; ?></td>
    <td align="center"><? echo $res['jk']; ?></td>
    <td align="center">&radic;</td>
    <td align="center">-</td>
    <td align="center">-</td>
    <form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=300');">
   <input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
   <input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
   <input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
   <input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
   <input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
    <input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
    <input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
    <input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
    <td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
    </form>
    </tr>
    <? } ?>
    </table>
	<? }
}elseif($kri=="nip"){
	include"index.php";
	?>
    <table border="1" cellspacing="0" cellpadding="0" vspace="0">
    <tr>
    <td>NIP</td>
    <td>Nama</td>
    <td>Departement</td>
    <td>Jenis Kelamin&nbsp;</td>
    <td>Kehadiran&nbsp;</td>
    <td>Jenis&nbsp;</td>
    <td>Keterangan&nbsp;</td>
    </tr>
    <?
    $sql=mysql_query("SELECT * FROM tabel_karyawan WHERE NIP LIKE '$txt%'")or die(mysql_error());
	if(mysql_num_rows($sql)==0){
		?><script language="javascript">alert("Data Tidak Ada");</script>
	<meta http-equiv="refresh" content="0;url=index.php"><?
	}else{
	while($res=mysql_fetch_array($sql)){
		$nik=$res['NIK'];
		$abs=mysql_query("SELECT * FROM tabel_absesn WHERE NIK LIKE '%$nik%' AND tanggal='$tgl'")or die(mysql_error());
		$sul=mysql_fetch_array($abs)
	?>
    <tr onmouseover="this.bgColor='#00FFFF'" onmouseout="this.bgColor='#FFFFFF'">
    <td><? echo $res['NIP']; ?></td>
    <td><? echo $res['Nama']; ?></td>
    <td><? echo $res['dept']; ?></td>
    <td align="center"><? echo $res['jk']; ?></td>
    <td align="center">&radic;</td>
    <td align="center">-</td>
    <td align="center">-</td>
    <form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=300');">
   <input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
   <input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
   <input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
   <input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
   <input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
    <input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
    <input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
    <input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
    <td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
    </form>
    </tr>
    <? } ?>
    </table>
	<? }
}else{
	echo"Gagal Mencari";
	?>
	<meta http-equiv="refresh" content="1;url=index.php">
    <?
}
?>

Semoga bermanfaat :)

Lihat semua 1 jawaban

Silahkan login untuk menjawab!
Mohon penjelasan dan solusinya.....
Saya punya table berkas berikut :
CREATE TABLE `riwayat_takah` (
  `nip` varchar(20) NOT NULL,
  `fid_takah` varchar(5) NOT NULL,
  `status` enum('ADA','TIDAK ADA') NOT NULL,
  `note` varchar(255) NOT NULL,
  KEY `id_takah` (`fid_takah`),
  KEY `nip` (`nip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `ref_takah` (
  `id_takah` varchar(5) NOT NULL,
  `nama_takah` varchar(255) NOT NULL,
  PRIMARY KEY  (`id_takah`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

jumlah record ref_takah 35 record, pada form yang saya buat data "status" ditampilkan dalam bentuk checkbox menggunakan array, sedangkan data "note" hanya ditampilkan jika checkbox status dicentang dan juga menggunakan array. ketika saya submit, yang berhasil insert ke database hanya data status, sedangkan isi dari textbox note tidak insert ke database.

Mohon bantuannya gimana supaya text yang diketikkan pada textbox note tersimpan dalam field note pada tabel riwayat_takah?

terima kasih...

Lihat semua 3 jawaban

Silahkan login untuk menjawab!
Mohon bantuan Agan2 skalian, saya coba koneksi dari PHP ke DB tapi selalu ada warning spt ini :

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\asramapoliteknik\administrator\login.php on line 27

terimakasih sebelumnya utk bantuannya.... ^_^
<?php
 
// memulai session
session_start();
 
include "../include/koneksi.php";
if(isset($_POST['Submit'])){
$username = $_POST['username'];
$password = $_POST['pass'];
if(empty($username)){
echo "<script type='text/javascript'>
onload =function(){
alert('Username belum diisi');
}
</script>";
}
elseif(empty($password)){
echo "<script type='text/javascript'>
onload =function(){
alert('Password belum diisi');
}
</script>";
} else {
// query untuk mendapatkan record dari username
$query = "SELECT * FROM user WHERE username = '$username'";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
 
// cek kesesuaian password
if ($password == $data['password'])
{
    header("location:index.php");
 
    // menyimpan username dan level ke dalam session
    $_SESSION['level'] = $data['level'];
    $_SESSION['username'] = $data['username'];
  
}
echo "<script type='text/javascript'>
onload =function(){
alert('Username atau password salah!! Ulangi kembali');
}
</script>";
}
}
?>

Lihat semua 5 jawaban

Silahkan login untuk menjawab!