initial commit
This commit is contained in:
commit
c80db110d2
12
koneksi.php
Normal file
12
koneksi.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$host="202.46.28.144";
|
||||
$user = "pw";
|
||||
$pass = "pwp";
|
||||
$database= "pw";
|
||||
|
||||
$conn = mysqli_connect($host,$user,$pass,$database);
|
||||
if (!$conn){
|
||||
die("Koneksi gagal");
|
||||
}
|
||||
else echo "Koneksi berhasil";
|
||||
?>
|
||||
45
login.php
Normal file
45
login.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
//untuk halaman login
|
||||
include "koneksi.php";
|
||||
if (isset($_POST['username']))
|
||||
{
|
||||
$username=$_POST['username'];
|
||||
}
|
||||
else $username ='';
|
||||
if (isset($_POST['password']))
|
||||
{
|
||||
$password=$_POST['password'];
|
||||
}
|
||||
else $password ='';
|
||||
if ($username!='' || $password!='')
|
||||
{
|
||||
$stmt = mysqli_prepare($conn,"select * from user where username=? and password=?");
|
||||
$enc=md5($password);
|
||||
mysqli_stmt_bind_param($stmt,"ss", $username,$enc);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
if ($row=mysqli_fetch_assoc($result))
|
||||
{
|
||||
echo "Login sukses";
|
||||
$_session['firstname'] = $row['firstname']; //simpan session firstname
|
||||
$_session['lastname'] = $row['lastname'];
|
||||
header("Location:dashboard.php"); //untuk pindah ke halaman dashboard.php
|
||||
|
||||
echo "firstname:".$row['firstname']."<br>";//kalo di file yang sama
|
||||
echo "lastname:".$row['lastname']."<br>";
|
||||
}
|
||||
else echo "Username/password salah";
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<form method="POST">
|
||||
Username: <input type="text" name="username"><br>
|
||||
Password:<input type="password" name="password"><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
60
week13.php
Normal file
60
week13.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
//untuk register
|
||||
include "koneksi.php"; // untuk memanggil koneksi.php
|
||||
/*if (isset($_POST['umur']))
|
||||
$umur = $_POST['umur'];
|
||||
else $umur=0;
|
||||
if ($umur<17)
|
||||
{echo "Belum boleh buat KTP<br>";}
|
||||
else if ($umur>60)
|
||||
echo "Tidak perlu buat KTP<br>";
|
||||
else echo "Sudah boleh buat KTP<br>";
|
||||
if (isset($_POST['n']))
|
||||
$n = $_POST['n'];
|
||||
else $n=0;
|
||||
//cetak segitiga
|
||||
for($i=1;$i<=$n;$i++)
|
||||
{
|
||||
for ($j=1;$j<=$i;$j++)
|
||||
{
|
||||
echo "*";
|
||||
}
|
||||
echo("<br>");
|
||||
}*/
|
||||
if (isset($_POST['username']))
|
||||
$username = $_POST['username'];
|
||||
else $username='';
|
||||
if (isset($_POST['firstname']))
|
||||
$firstname = $_POST['firstname'];
|
||||
else $firstname='';
|
||||
if (isset($_POST['lastname']))
|
||||
$lastname = $_POST['lastname'];
|
||||
else $lastname='';
|
||||
if (isset($_POST['password']))
|
||||
$password = md5($_POST['password']);
|
||||
else $password='';
|
||||
|
||||
//insert data ke table user_error
|
||||
if ($username!='' || $firstname='' || $lastname='' || $password='')
|
||||
{
|
||||
$sql ="insert into user(username, firstname, lastname, password) values('$username', '$firstname', '$lastname','$password')";
|
||||
if (mysqli_query($conn,$sql)){
|
||||
echo "insert berhasil";}
|
||||
else echo "error:",mysqli_error($conn);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<form method="POST">
|
||||
Username: <input type="text" name="username"><br>
|
||||
Firstname:<input type="text" name="firstname"><br>
|
||||
Lastname:<input type="text" name="lastname"><br>
|
||||
Password:<input type="text" name="password"><br>
|
||||
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
82
weektigabelas.php
Normal file
82
weektigabelas.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
include 'koneksi.php';
|
||||
$data = mysqli_query($conn, "SELECT KODE_BARANG, NAMA_BARANG, HARGA_JUAL, STOK FROM BARANG");
|
||||
?>
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
#container{
|
||||
display: grid;
|
||||
position: static;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
|
||||
#container > div{
|
||||
border: 2px solid;
|
||||
border-radius: 10px;
|
||||
margin: 5px;
|
||||
width:350px;
|
||||
height: 400px;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
#container > div:hover{
|
||||
scale: 1.02;
|
||||
}
|
||||
|
||||
.header{
|
||||
font-weight: bold;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.kedua{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.kedua > div{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
img{
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
iframe{
|
||||
width: 200px;
|
||||
height: 115px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<?php
|
||||
while ($d =mysqli_fetch_assoc($data))
|
||||
{
|
||||
echo "<div><div class='header'>".$d['NAMA_BARANG']."</div>";
|
||||
echo "<img src='asset/".$d['KODE_BARANG'] .".jpg'>";
|
||||
echo "<div>".$d['HARGA_JUAL']."</div>";
|
||||
echo "<button>Buy</button>
|
||||
<button>Details</button>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="header">A a</div>
|
||||
<div class="kedua">
|
||||
<div>a</div>
|
||||
<div>a</div>
|
||||
</div>
|
||||
<img src="bg.jpg">
|
||||
<div>ayam</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user