session_start(); if($_SESSION['username']) { echo""; } if (isset($_POST['login'])) { include 'Configuration/Config.php'; $username = addslashes(strip_tags($_POST['username'])); $password = addslashes(strip_tags($_POST['password'])); if (!$username||!$password) $error = "Enter username & password"; else { $login = $con->Query("SELECT * FROM PPI_Users WHERE username = '$username'"); if (mysqli_num_rows($login)==0) $error = "No such user"; else { while ($login_row = mysqli_fetch_assoc($login)) { $password_db = $login_row['password']; $password = md5($password); if ($password!=$password_db) $error = "Incorrect password"; else { session_start(); setcookie("loggedin", "true", time()+1800); $_SESSION['username'] = $username; header("location:welcome.php"); } } } } } else { $error = "USER ACCESS"; } ?>