Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.16 KB | None | 0 0
  1.  
  2.  
  3. <!DOCTYPE html>
  4. <?php
  5.  
  6. require_once("config.php");
  7.  
  8. $namaserver = "localhost";
  9. $username = "root";
  10. $password = "";
  11. $namadb = "pelumas";
  12. $koneksi_db = mysqli_connect($namaserver, $username, $password, $namadb);
  13.  
  14. if(isset($_POST['login'])){
  15.  
  16. $nim = filter_input(INPUT_POST, 'nim', FILTER_SANITIZE_STRING);
  17. $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
  18.  
  19. if (empty($nim) || empty($password)){
  20. echo "<script>alert(' NIM dan Password harus diisi');history.go(-1);</script>";
  21. }
  22.  
  23. else{
  24. $sql = "SELECT * FROM akun WHERE nim=:nim OR emailmhs=:emailmhs";
  25. $stmt = $db->prepare($sql);
  26.  
  27. // bind parameter ke query
  28. $params = array(
  29. ":nim" => $nim,
  30. ":emailmhs" => $nim
  31. );
  32.  
  33. $stmt->execute($params);
  34.  
  35. $user = $stmt->fetch(PDO::FETCH_ASSOC);
  36.  
  37. // jika user terdaftar
  38. if($user){
  39. // verifikasi password
  40. if(password_verify($password, $user["password"])){
  41. // buat Session
  42. session_start();
  43. $_SESSION["user"] = $user;
  44. // login sukses, alihkan ke halaman timeline
  45. header("Location: loged.php");
  46. }
  47. }
  48. }
  49. }
  50.  
  51. ?>
  52.  
  53.  
  54. <!--
  55. To change this license header, choose License Headers in Project Properties.
  56. To change this template file, choose Tools | Templates
  57. and open the template in the editor.
  58. -->
  59. <html>
  60. <head>
  61. <title>Selamat Datang di Website Pelumas</title>
  62. <meta charset="UTF-8">
  63. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  64. <link rel="stylesheet" href="css/style-login.css" />
  65. <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  66. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous">
  67. </head>
  68. <body>
  69. <div class="container">
  70. <!-- Start Header -->
  71. <div class="header">
  72.  
  73. <a href="index.php"><img src="image/logo.png" alt="" /> </a>
  74. <!-- start Login -->
  75. <?php session_start();
  76. if(!isset($_SESSION["user"])){ ?>
  77. <form class="login" method="POST">
  78. <div class="sa">
  79. <h5>NIM:</h5>
  80. <input type="text" placeholder="Masukkan NIM" name="nim">
  81. <div class="button">
  82. <input type="submit" value="Login" name="login" class="ro" style="border:none">
  83. <a href='register.php'" class="rg">Register</a>
  84. </div>
  85. </div>
  86. <div class="du">
  87. <h5>PASSWORD:</h5>
  88. <input type="password" placeholder="Masukkan Password" name="password">
  89. </div>
  90.  
  91.  
  92.  
  93. </form>
  94. <?php }
  95.  
  96. else{ ?>
  97.  
  98. <div class="loged">
  99. <div class="sa">
  100. <h2><i class="far fa-user"></i> Hy, <?php echo $_SESSION["user"]["nama"] ?></h2>
  101. <a href="logout.php" class="lo">Logout</a>
  102. </div>
  103.  
  104.  
  105. </div>
  106. <?php }
  107.  
  108. ?>
  109.  
  110.  
  111.  
  112.  
  113. <!-- End Login -->
  114. <div class="clear"></div>
  115.  
  116. <div class="batas"></div>
  117. </div>
  118. <!-- End Header -->
  119. <!-- Start Isi -->
  120. <div class="isi">
  121. <div class="banner">
  122. <p>
  123. Punya Keluhan dikampus? Barang kesayangan mu hilang? atau kamu menemukan sesuatu?
  124. Laporkan saja disini.
  125. </p>
  126.  
  127. <button class="mklapor" onclick="<?php
  128.  
  129. if(!isset($_SESSION["user"])){ ?>alert('Anda harus Login dulu!');
  130.  
  131.  
  132. <?php }
  133. else{ ?>
  134. window.location.href='formlapor.php'
  135.  
  136. <?php }
  137. ?>";>Buat Laporan</button>
  138. </div>
  139.  
  140. <div class="laporan">
  141.  
  142. <div class="title">
  143.  
  144. <h4>Data Laporan Terkini!</h4>
  145. </div>
  146. <div class="tab1">
  147. <div class="tabkehilangan">
  148. <h2> Kehilangan </h2>
  149.  
  150. </div>
  151.  
  152. <div class="over">
  153.  
  154.  
  155. <?php
  156.  
  157. //buat skrip querry sql
  158. $strSQL = "SELECT idlaporan, pelapor, isi, tanggal FROM datalapor WHERE kategori='kehilangan' ORDER BY idlaporan DESC";
  159.  
  160. //echo $strSQL;
  161.  
  162. //Eksekusi skrip
  163. $hasil = mysqli_query($koneksi_db, $strSQL);
  164. //cek data ada atau tidak
  165. $jmlRows = mysqli_num_rows($hasil); //menghitung jumlah rows
  166.  
  167.  
  168. if($jmlRows > 0){
  169. $nomor = 0;
  170. while($row = mysqli_fetch_assoc($hasil)){
  171. $nomor = $nomor + 1;
  172. $idlaporan = $row["idlaporan"];
  173. $pelapor = $row["pelapor"];
  174. $isi = $row["isi"];
  175. $tanggal = $row["tanggal"];
  176.  
  177. ?>
  178. <div class="berita">
  179. <div class="pembuka">
  180.  
  181. </div>
  182.  
  183. <p> <?php echo substr($isi, 0,65); ?> ...</p>
  184. <a href="detail.php?page=detail&idlaporan=<?php echo $idlaporan; ?>" style="">Selengkapnya</a>
  185.  
  186. <div class="penutup">
  187.  
  188. </div>
  189.  
  190. <li><?php $pelapor = ucwords($pelapor);
  191. echo $pelapor."&nbsp &nbsp <strong> | </strong>"; ?> </li>
  192. <li><?php echo "", date('d F Y', strtotime($tanggal)); ?></li>
  193.  
  194. </div>
  195. <?php }
  196. } ?> </div>
  197. </div>
  198.  
  199. <div class="tab2">
  200. <div class="tabpenemuan">
  201. <h2> Penemuan </h2>
  202.  
  203. </div>
  204.  
  205. <div class="over">
  206. <?php
  207.  
  208. //buat skrip querry sql
  209. $strSQL = "SELECT idlaporan, pelapor, isi, tanggal FROM datalapor WHERE kategori='penemuan' ORDER BY idlaporan DESC";
  210.  
  211. //echo $strSQL;
  212.  
  213. //Eksekusi skrip
  214. $hasil = mysqli_query($koneksi_db, $strSQL);
  215. //cek data ada atau tidak
  216. $jmlRows = mysqli_num_rows($hasil); //menghitung jumlah rows
  217.  
  218.  
  219. if($jmlRows > 0){
  220. $nomor = 0;
  221. while($row = mysqli_fetch_assoc($hasil)){
  222. $nomor = $nomor + 1;
  223. $idlaporan = $row["idlaporan"];
  224. $pelapor = $row["pelapor"];
  225. $isi = $row["isi"];
  226. $tanggal = $row["tanggal"];
  227.  
  228. ?>
  229. <div class="berita">
  230. <div class="pembuka">
  231.  
  232. </div>
  233.  
  234. <p> <?php echo substr($isi, 0,65); ?> ...</p>
  235. <a href="detail.php?page=detail&idlaporan=<?php echo $idlaporan; ?>" style="">Selengkapnya</a>
  236.  
  237. <div class="penutup">
  238.  
  239. </div>
  240.  
  241. <li><?php echo ucwords($pelapor),"&nbsp &nbsp <strong> | </strong>"; ?> </li>
  242. <li><?php echo "", date('d F Y', strtotime($tanggal)); ?></li>
  243.  
  244. </div>
  245. <?php }
  246. } ?>
  247. </div>
  248. </div>
  249.  
  250. <div class="tab3">
  251. <div class="tabkeluhan">
  252. <h2> Keluhan Mahasiswa</h2>
  253. </div>
  254. <div class="over">
  255. <?php
  256.  
  257. //buat skrip querry sql
  258. $strSQL = "SELECT idlaporan, pelapor, isi, tanggal FROM datalapor WHERE kategori='keluhan' ORDER BY idlaporan DESC";
  259.  
  260. //echo $strSQL;
  261.  
  262. //Eksekusi skrip
  263. $hasil = mysqli_query($koneksi_db, $strSQL);
  264. //cek data ada atau tidak
  265. $jmlRows = mysqli_num_rows($hasil); //menghitung jumlah rows
  266.  
  267.  
  268. if($jmlRows > 0){
  269. $nomor = 0;
  270. while($row = mysqli_fetch_assoc($hasil)){
  271. $nomor = $nomor + 1;
  272. $idlaporan = $row["idlaporan"];
  273. $pelapor = $row["pelapor"];
  274. $isi = $row["isi"];
  275. $tanggal = $row["tanggal"];
  276.  
  277. ?>
  278. <div class="berita">
  279. <div class="pembuka">
  280.  
  281. </div>
  282.  
  283. <p> <?php echo substr($isi, 0,65); ?> ...</p>
  284. <a href="detail.php?page=detail&idlaporan=<?php echo $idlaporan; ?>" style="">Selengkapnya</a>
  285.  
  286. <div class="penutup">
  287.  
  288. </div>
  289.  
  290. <li><?php $pelapor = ucwords($pelapor);
  291. echo $pelapor."&nbsp &nbsp <strong> | </strong>"; ?> </li>
  292. <li><?php echo "", date('d F Y', strtotime($tanggal)); ?></li>
  293.  
  294. </div>
  295. <?php }
  296. } ?>
  297. </div>
  298.  
  299. </div>
  300.  
  301. </div>
  302.  
  303. </div>
  304.  
  305. </div>
  306. <!-- End Isi -->
  307.  
  308. <h3 style="margin-top: 100px;margin-bottom: 5px;font-size: 15px">@COPYRIGHT By</h3>
  309. <h3 style="margin: 0;padding: 0">INFORMATIKA 2016</h3>
  310. <div class="footer">
  311.  
  312. </div>
  313. </div>
  314. </body>
  315. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement