Advertisement
Guest User

Untitled

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