Gifari Industries - BD Cyber Security Team
Home
/
home
/
decohaslibrary
/
studentrecruitment.decohaslibrary.ac.tz
/
✏️
Editing: login.php
<?php session_start(); if(isset($_SESSION['user_id'])) { header("location:login"); } require_once 'conn.php'; if(ISSET($_POST['login'])){ if($_POST['username'] != "" || $_POST['password'] != ""){ $username = $_POST['username']; $password = md5($_POST['password']); $sql = "SELECT * FROM `student` WHERE `username`=? AND `password`=? "; $query = $conn->prepare($sql); $query->execute(array($username,$password)); $row = $query->rowCount(); $fetch = $query->fetch(); if($row > 0) { $_SESSION['user'] = $fetch['user_id']; $_SESSION['username'] = $fetch['username']; $_SESSION['first_name'] = $fetch['first_name']; $_SESSION['last_name'] = $fetch['last_name']; $_SESSION['middle_name'] = $fetch['middle_name']; $_SESSION['department'] = $fetch['department']; $user_role = $fetch['user_role']; if($user_role=="student") { header("location:cont!!!..._~~@!!form4!student"); } }else{ echo " <script>alert('Invalid username or password')</script> <script>window.location = 'index.php'</script> "; } }else{ echo " <script>alert('Please complete the required field!')</script> <script>window.location = 'index.php'</script> "; } } ?>
💾 Save
❌ Cancel