Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************/
- FILE: login.php
- <table width="429" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="429" height="15" bgcolor="#333333"><h3 align="center" class="style1">PORTAL SISTEM AKADEMIKA </h3></td>
- </tr>
- <tr>
- <td height="162" bgcolor="#CCCCCC">
- <form action="proses.php" method="post">
- <div align="justify"></div>
- <table width="310" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td width="97"><span class="style4">Username </span></td>
- <td width="267">
- <input type="text"
- name="username"
- size="25"
- placeholder="Masukan Username Anda" />
- </td>
- </tr>
- <tr>
- <td height="41"><span class="style4">Password </span></td>
- <td>
- <input type="password"
- name="password"
- size="25"
- placeholder="Masukan Password Anda"/>
- </td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="submit" name="submit" value="LOGIN"></td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
- /*******************/
- FILE: process.php
- <?php
- session_start(); //memulai session
- include "konek.php";
- $msg='';
- // check submit
- if(isset($_POST['submit']))
- {
- //query untuk mengambil data user dari database sesuai dengan username inputan form
- $sql = "SELECT level,username
- FROM user
- WHERE username = '".$_POST['username']."' AND password='".$_POST['password']."'";
- if($result = mysql_query($sql))
- {
- if (mysql_num_rows($result)==1)
- {
- //menyimpan tipe user dan username dalam session
- $_SESSION['level'] = $data['level'];
- $_SESSION['username'] = $data['username'];
- //redirect halaman sesuai 'level'-nya
- header('location:'.$data['level'].'/home_'.$data['level'].'.php');
- }
- //jika password/username tidak sesuai
- else
- {
- $msg='Username / Password Salah atau tidak ditemukan';
- }
- }
- else
- {
- $msg='Terjadi kesalahan pada database';
- }
- }
- else
- {
- $msg='Anda tidak berhak mengakses halaman ini langsung';
- }
- echo "<center><font color='red'>$msg</font><br><a href='index.php'>Kembali</a></center>";
- ?>
- /*******************/
- FILE: session.php
- <?php
- session_start();
- if ($_SESSION['level'] == "admin")
- {
- header('location:admin/home_admin.php');
- }
- elseif ($_SESSION['level'] == "user")
- {
- header('location:user/home_user.php');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement