<commit_before><?php
 require 'database-config.php';

 session_start();

 $username = "";
 $password = "";

 if(isset($_POST['username'])){
  $username = $_POST['username'];
 }
 if (isset($_POST['password'])) {
  $password = $_POST['password'];

 }


 $q = 'SELECT * FROM biodata WHERE username=:username AND password=:password';

 $query = $dbh->prepare($q);

 $query->execute(array(':username' => $username, ':password' => $password));


 if($query->rowCount() == 0){
  header('Location: index.php?err=1');
 }else{

  $row = $query->fetch(PDO::FETCH_ASSOC);

  session_regenerate_id();
  $_SESSION['sess_user_id'] = $row['id'];
  $_SESSION['sess_username'] = $row['username'];
        $_SESSION['sess_userrole'] = $row['role'];

        echo $_SESSION['sess_userrole'];
  session_write_close();

  if( $_SESSION['sess_userrole'] == "admin"){
   header('Location: adminhome.html');
  }else if( $_SESSION['sess_userrole'] == "staff"){
   header('Location: staffhome.html');
  }else{
   header('location: svhome.html');
  }


 }


?><commit_msg>new login but no session yet<commit_after><?php
 require 'database-config.php';

 session_start();

 $username = "";
 $password = "";

 if(isset($_POST['username'])){
  $username = $_POST['username'];
 }
 if (isset($_POST['password'])) {
  $password = $_POST['password'];

 }


 $q = 'SELECT * FROM biodata WHERE username=:username AND password=:password';

 $query = $dbh->prepare($q);

 $query->execute(array(':username' => $username, ':password' => $password));


 if($query->rowCount() == 0){
  header('Location: index.php?err=1');
 }else{

  $row = $query->fetch(PDO::FETCH_ASSOC);

  session_regenerate_id();
  $_SESSION['sess_user_id'] = $row['id'];
  $_SESSION['sess_username'] = $row['username'];
        $_SESSION['sess_userrole'] = $row['role'];

        echo $_SESSION['sess_userrole'];
  session_write_close();
  $role =   $_SESSION['sess_userrole'] = $row['role'];
  switch($role){
      case ($_SESSION['sess_userrole'] == "admin"):
          header('Location: adminhome.html');
          break;
      case $_SESSION['sess_userrole'] == "staff":
          header('Location: staffhome.html');
          break;
      case $_SESSION['sess_userrole'] == "supervisor":
          header('Location: svhome.html');
          break;
      case $_SESSION['sess_userrole'] == "manager":
          header('Location: mgrhome.html');
          break;
        }
/*
  if( $_SESSION['sess_userrole'] == "admin"){
   header('Location: adminhome.html');
  }else if( $_SESSION['sess_userrole'] == "staff"){
   header('Location: staffhome.html');
  }else{
   header('location: svhome.html');
  }
*/

 }


?>
{'fraction_non_alphanumeric': 0.2120982986767486, 'fraction_numerical': 0.0015122873345935729, 'mean_word_length': 4.198428290766208, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4694542', 'n_tokens_mistral': 897, 'n_tokens_neox': 853, 'n_words': 149}