Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. include 'dbConnect.php';
  5. function loginaction(){
  6. include 'dbConnect.php';
  7. $time = time();
  8.  
  9. if(isset($_GET['Key'])){
  10. //$myusername = $_GET['operator_id'];
  11. $key = $_GET['telegram_key'];
  12.  
  13.  
  14. //$query = $db->prepare("SELECT * FROM telegramlog WHERE operator_id = ? and telegram_key = ?;");
  15. $query = $db->prepare("SELECT operators.operator_id, telegramlog.telegram_key FROM
  16. telegramlog LEFT JOIN operators ON telegramlog.operator_id = operators.operator_id WHERE telegramlog.telegram_key = ? ;");
  17.  
  18. $query->execute(array($_GET['Key']($key)));
  19. $count = $query->rowCount();
  20. $result = $query->fetchAll();
  21.  
  22.  
  23. }
  24. if($result){
  25. header('location: user.php');
  26. }
  27. else{
  28. echo ' no result';
  29. }
  30.  
  31.  
  32. }
  33.  
  34. if(isset($_POST['Login'])){
  35. $username=$_POST['user'];
  36. $password=$_POST['pass'];
  37.  
  38. $query = $db->prepare("SELECT * FROM operators WHERE email = ? and heslo = ?;");
  39. $result = $query->execute(array($username,$password));
  40.  
  41.  
  42. if($result){
  43. while($row = $query ->fetch(PDO::FETCH_ASSOC)){
  44. echo '<script type="text/javascript">alert("You are logged in as user '. $row['users'] . '")</script>';
  45. if($row['users']=="a"){
  46. header('location: admin.php');
  47. }
  48. elseif($row['users']=="b"){
  49. header('location: leader.php');
  50. }
  51. elseif($row['users']=="c"){
  52. header('location: user.php');
  53. }
  54. else{
  55. echo ' no result';
  56. }}}}
  57. loginaction();
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement