Postingan lainnya
cara atasi error session_start() php mysql?
bisa bantu cara fix ini " Warning: session_start() expects parameter 1 to be array, int given in C:\xampp\htdocs\penduduk\valid.php on line 3"
index.php
}
.box {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
}
.box video {
min-width: 100%;
min-height: 100%;
}
.header-overlay {
height: 100vh;
width: 100vw;
position: absolute;
top: 0;
left: 0;
background-color: rgba(0, 0, 45, 1);
background: rgba(0, 0, 45, 1)
z-index: 1;
opacity: 0.85;
}
.content {
z-index: 99;
width: 100%;
margin: auto;
}
.content h1{
font-size: 50px;
}
a {
border: 2px solid #f90;
color: #fff;
font-size: 1.2rem;
padding: 10px;
text-decoration: none;
}
</style>
</head>
<body class="hold-transition login-page">
<header class="wrapper head">
<div class="box">
<video src="delisman.mp4" autoplay loop="true"></video>
</div>
<div class="content">
<div class="login-box">
<div class="login-logo">
<H2>USER LOGIN </H2>
</div>
<div class="login-box-body">
<form action="login.php" method="post">
<div class="form-group has-feedback">
<input type="text" class="form-control" name="txtusername" placeholder="User Name">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="txtpassword" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" name="btnlogin" class="btn btn-primary btn-block btn-flat">LOGIN</button> <br><br>
</div>
<!-- /.col -->
</div>
</form>
</div>
</div>
</div>
</header>
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
});
</script>
login.php
<?php
include'koneksi.php';
if(isset($_POST["btnlogin"])){
$txtusername =$_POST['txtusername'];
$txtpassword =$_POST['txtpassword'];
$cek = mysqli_query($konek, "SELECT * FROM tbl_user where user_name='".$_POST['txtusername']."' AND password='".$_POST['txtpassword']."'");
$hasil = mysqli_fetch_array($cek);
$count = mysqli_num_rows($cek);
$nama1 =$hasil['user_name'];
if($count >0){
session_start();
$_SESSION['user_name']=$nama1;
header("location:beranda.php");
}
else{
// echo "";
}
}
?>
<div class="pages_agile_info_w3l page_error">
<div class="over_lay_agile_pages_w3ls error">
<div class="registration error">
<br><br><br>
<h1 align="center">Oops! Login Salah </h1>
<br><br><br><br><br><br><br><br><br>
<h1 align="center"><a href="index.php">Coba Lagi</a><h1>
</div>
</div>
</div>
valid.php
<?php
include'koneksi.php';
session_start(0);
if (empty($_SESSION['user_name'])){
// header("location:index.php");
echo "<h1>Harap Login</H1>"; die("Belum Login <a href=\"javascript:history.back()\">Back</a>");
}else{
// echo "LOGIN BERHASIL";
?>
<?php } ?>
koneksi.php
<?php
$server= 'localhost';
$user= 'root';
$password= '';
$database= 'penduduk';
$konek= mysqli_connect($server,$user,$password,$database);
if ($konek){
echo "";
}else
{
echo "GAGAL KONEK KE DATABASE";
}
?>
1 Jawaban:
<div>Kode kamu yang ini :</div><pre><?php include'koneksi.php'; session_start(0); if (empty($_SESSION['user_name'])){ // header("location:index.php"); echo "<h1>Harap Login</H1>"; die("Belum Login <a href="javascript:history.back()">Back</a>"); }else{ // echo "LOGIN BERHASIL"; ?> <?php } ?></pre><div><br>Hapus angka 0 di bagian session_start(); <br>Silahkan baca-baca di dokumentasi resminya disini <a href="https://www.php.net/manual/en/function.session-start.php">https://www.php.net/manual/en/function.session-start.php</a><br>Semoga berhasil.</div>