Menambahkan fungsi login dan login proses

parent 28dddf56
<?php
require_once(dirname(__FILE__).'/header.php');
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/stylee.css" />
<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BUKIT GIBEON</title>
<link rel="shortcut icon" href="images/inst.png">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/myStyle.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body background="images/bg.jpg" width="0px">
<body>
<div class="containers">
<section>
<div id="container_demo" >
<a class="hiddenanchor" id="toregister"></a>
<br><br><br><br><br><a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form">
<form action="login_proses.php" autocomplete="on" method="POST">
<h1>Log in</h1>
<p>
<label for="username" class="uname" > Your email or username </label>
<input id="username" name="username" type="text" placeholder="enter username"/>
</p>
<p>
<label for="password" class="youpasswd" > Your password </label>
<input id="password" name="password" type="password" placeholder="masukkan passoword" />
</p>
<p class="login button">
<input type="submit" value="Login" />
</p>
<p class="change_link">
Not a member yet ?
<a href="#toregister" class="to_register">Mendaftar</a>
</p>
</form>
</div>
<div id="register" class="animate form">
<form action="tambah_proses.php" method="POST">
<h1> Sign up </h1>
<p>
<label for="nama" class="nama" > Nama Lengkap</label>
<input id="namalengkap" name="namalengkap" required="required" type="text" placeholder="Masukkan Nama Lengkap"/>
</p>
<p>
<label for="alamat" class="alamat" > alamat</label>
<input id="alamat" name="alamat" required="required" type="text" placeholder="Masukkan alamat"/>
</p>
<p>
<label for="email" class="email" > email</label>
<input id="email" name="email" required="required" type="int" placeholder="Masukkan email"/>
</p>
<p>
<label for="username" class="uname" >Masukkan Username </label>
<input id="username" name="username" required="required" type="text" placeholder="Masukkan Username"/>
</p>
<p>
<label for="password" class="youpasswd" >Masukkan password </label>
<input id="password" name="password" required="required" type="password" placeholder="Masukkan Password"/>
</p>
<p class="signin button">
<input type="submit" value="Daftar"/>
</p>
<p class="change_link">
Already a member ?
<a href="#tologin" class="to_register"> Go and log in </a>
</p>
</form>
</div>
</div>
</div>
</section>
</div>
</body>
</html>
\ No newline at end of file
<?php
session_start();
require_once('fungsi.php');
$username =$_POST ['username'];
$password =$_POST['password'];
$query = "select * from user where username='".$username."' and password='".$password."'";
$sql = mysql_query($query);
$check = mysql_num_rows($sql);
$r = mysql_fetch_array($sql);
if($check>=0){
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['role'] = $r['role'];
if($r['role']=='admin'){
header('LOCATION: home.php');
$_SESSION['admin'] = TRUE;
}elseif($r['role']=='user'){
header('LOCATION: index.php');
$_SESSION['user'] = TRUE;
$_SESSION['is_logged_in']=TRUE;
$_SESSION['username']=$username;
}
elseif($r['username'] != $username && $r['password'] != $password){
echo "<script language='javascript'>alert('cek username dan Password anda')</script>";
echo "<script>window.location = 'pengunjung.php'</script>";
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment