Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include 'db_connection.php';
- session_start();
- if(isset($_POST['login'])){
- if(!empty($_POST['username']) && !empty($_POST['password']){
- $get_username=mysqli_real_escape_string($conn,$_POST['username'];
- $get_password=mysqli_escape_string($conn,$_POST['password'];
- $sql = "SELECT * FROM EMPLOYEES WHERE EMP_USERNAME = '$get_username' AND EMP_PASSWORD = '$get_password'");
- if($result = mysqli_query($conn,$sql)){
- if(mysqli_num_rows($result) == 1{
- $_SESSION['username'] = $get_username;
- $_SESSION['password'] = $get_password;
- header("Location:../index.php");
- }else{
- header("Location:../index.php?login=wrong");
- }
- }else{
- header("Location:../index.php?login_error=query_error");
- }
- }else{
- header("Location:../index.php?login_error=login_empty");
- }
- }
- <?php
- $servername = "localhost";
- $username = "root";
- $password= "";
- $dbname = users;
- $conn = new mysqli($servername, $username,$password,$dbname);
- if($conn->connect_error){
- die("connection failed: ".$conn->connect_error);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement