<?php
session_start();
include "koneksi.php";
$user = $_POST['user'];
$pass = $_POST['pass'];
$mysql = mysql_query("SELECT * FROM login WHERE user='$user' AND pass='$pass'");
$xxx=mysql_num_rows($mysql);
if($xxx==TRUE){
$_SESSION['user'] = $user;
echo "<script>window.alert('Login Berhasil');
window.location=('read.php')
</script>";
}else{
echo "<script>window.alert('Username atau Password Salah');
window.location=('login.php')
</script>";
}
?>
Senin, 08 Juni 2015
form_login
<html>
<head>
</head>
<body>
<table>
<form action="validasi.php" method="POST">
<tr>
<td><input type="text" name="user" placeholder="Username"></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Password"></td>
</tr>
<tr>
<td><input type="Submit" name="Submit" placeholder="Submit"></td>
</tr>
</form>
</table>
</body>
</html>
<head>
</head>
<body>
<table>
<form action="validasi.php" method="POST">
<tr>
<td><input type="text" name="user" placeholder="Username"></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Password"></td>
</tr>
<tr>
<td><input type="Submit" name="Submit" placeholder="Submit"></td>
</tr>
</form>
</table>
</body>
</html>
hapus
<?php
include "db.php";
$kode = $_GET['kode'];
$query = mysql_query("delete from menu where kode='$kode'");
if($query){
echo "<script>window.alert('Hapus Berhasil');
window.location=('read.php')
</script>";
}else{
echo "<script>window.alert('Hapus Gagal');
window.location=('read.php.php')
</script>";
}
?>
include "db.php";
$kode = $_GET['kode'];
$query = mysql_query("delete from menu where kode='$kode'");
if($query){
echo "<script>window.alert('Hapus Berhasil');
window.location=('read.php')
</script>";
}else{
echo "<script>window.alert('Hapus Gagal');
window.location=('read.php.php')
</script>";
}
?>
edit1
<?php
include "db.php";
$kode = $_POST['kode'];
$nama_menu = $_POST['nama_menu'];
$harga = $_POST['harga'];
$query = mysql_query("update menu set nama_menu='$nama_menu', harga='$harga' where kode='$kode'");
if($query){
echo "<script>window.alert('Edit Berhasil');
window.location=('read.php')
</script>";
}else{
echo "<script>window.alert('Edit Gagal');
window.location=('edit.php')
</script>";
}?>
include "db.php";
$kode = $_POST['kode'];
$nama_menu = $_POST['nama_menu'];
$harga = $_POST['harga'];
$query = mysql_query("update menu set nama_menu='$nama_menu', harga='$harga' where kode='$kode'");
if($query){
echo "<script>window.alert('Edit Berhasil');
window.location=('read.php')
</script>";
}else{
echo "<script>window.alert('Edit Gagal');
window.location=('edit.php')
</script>";
}?>
edit
<?php
include "db.php";
$kode = $_GET['kode'];
$hasil = mysql_query("select * from menu where kode='$kode'");
$buff = mysql_fetch_array($hasil);
?>
<html>
<head>
</head>
<body>
<form action="edit1.php" method="POST">
<table>
<tr>
<td>Kode Menu<td>
<td><input type="text" name="kode" value="<?php echo $buff['kode'];?>"><td>
</tr>
<tr>
<td>Nama Menu<td>
<td><input type="text" name="nama_menu" value="<?php echo $buff['nama_menu'];?>"><td>
</tr>
<tr>
<td>Harga Menu<td>
<td><input type="text" name="harga" value="<?php echo $buff['harga'];?>"><td>
</tr>
<td><input type="submit" name="submit" value="Submit"></td>
</body>
</html>
include "db.php";
$kode = $_GET['kode'];
$hasil = mysql_query("select * from menu where kode='$kode'");
$buff = mysql_fetch_array($hasil);
?>
<html>
<head>
</head>
<body>
<form action="edit1.php" method="POST">
<table>
<tr>
<td>Kode Menu<td>
<td><input type="text" name="kode" value="<?php echo $buff['kode'];?>"><td>
</tr>
<tr>
<td>Nama Menu<td>
<td><input type="text" name="nama_menu" value="<?php echo $buff['nama_menu'];?>"><td>
</tr>
<tr>
<td>Harga Menu<td>
<td><input type="text" name="harga" value="<?php echo $buff['harga'];?>"><td>
</tr>
<td><input type="submit" name="submit" value="Submit"></td>
</body>
</html>
read
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<td>Kode</td>
<td>Menu</td>
<td>Harga</td>
<td>Action</td>
</tr>
<?php
include "db.php";
$hasil = mysql_query("select * from menu");
while ($buff = mysql_fetch_array($hasil)) {
?>
<td><?php echo $buff['kode'];?></td>
<td><?php echo $buff['nama_menu'];?></td>
<td><?php echo $buff['harga'];?></td>
<td><a href="edit.php?kode=<?php echo $buff['kode'];?>">Edit</a>
<a href="hapus.php?kode=<?php echo $buff['kode']; ?>"> Hapus</a></td>
</tr>
<?php }?>
</table>
</body>
</html>
<head>
</head>
<body>
<table border="1">
<tr>
<td>Kode</td>
<td>Menu</td>
<td>Harga</td>
<td>Action</td>
</tr>
<?php
include "db.php";
$hasil = mysql_query("select * from menu");
while ($buff = mysql_fetch_array($hasil)) {
?>
<td><?php echo $buff['kode'];?></td>
<td><?php echo $buff['nama_menu'];?></td>
<td><?php echo $buff['harga'];?></td>
<td><a href="edit.php?kode=<?php echo $buff['kode'];?>">Edit</a>
<a href="hapus.php?kode=<?php echo $buff['kode']; ?>"> Hapus</a></td>
</tr>
<?php }?>
</table>
</body>
</html>
input
<?php
include "db.php";
$nama_menu = $_POST['nama_menu'];
$harga = $_POST['harga'];
$query=mysql_query("insert into menu values('null','$nama_menu','$harga')");
if($query){
echo "<script>window.alert('Input Berhasil');
window.location=('form_input.php')
</script>";
}else{
echo "<script>window.alert('Input Gagal');
window.location=('input.php')
</script>";
}
?>
include "db.php";
$nama_menu = $_POST['nama_menu'];
$harga = $_POST['harga'];
$query=mysql_query("insert into menu values('null','$nama_menu','$harga')");
if($query){
echo "<script>window.alert('Input Berhasil');
window.location=('form_input.php')
</script>";
}else{
echo "<script>window.alert('Input Gagal');
window.location=('input.php')
</script>";
}
?>
form_input
<html>
<head>
</head>
<body>
<form method="POST" action="input.php">
<table>
<tr>
<td><input type="text" name="nama_menu" placeholder="Nama Menu"></td>
</tr>
<td><input type="text" name="harga" placeholder="Harga Menu"></td>
</tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
<head>
</head>
<body>
<form method="POST" action="input.php">
<table>
<tr>
<td><input type="text" name="nama_menu" placeholder="Nama Menu"></td>
</tr>
<td><input type="text" name="harga" placeholder="Harga Menu"></td>
</tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
Langganan:
Postingan (Atom)