daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <link rel="stylesheet" type="text/css" href="style.css">
  2. <script src="jquery.min.js"></script>
  3. <script src="login.js"></script>
  4. <div class="loginform-in">
  5. <h1>User Login</h1>
  6. <div class="err" id="add_err"></div>
  7. <fieldset>
  8.     <form action="login.php" method="post">
  9.             <label for="name">Username </label>
  10.             <input type="text" size="30"  name="name" id="name">
  11.             <label for="name">Password</label>
  12.             <input type="text" size="30"  name="word" id="word">
  13.  
  14.             <input type="radio" id="pac" name="sick" value="pac">Я доктор
  15.             <input type="radio" id="doc" name="sick" value="doc">Я пациент
  16.             <br>
  17.             <input type="submit" id="login" name="loginin" value="Войти" class="loginbutton">
  18.          </form>    
  19. </fieldset>
  20. </div>
  21.    
  22. /*------------ДОКТОР------------*/
  23. $(document).ready(function() {
  24.     $("#add_err").css('display', 'none', 'important');
  25.      $("#login").click(function() {
  26.           username=$("#name").val();
  27.           password=$("#word").val();
  28.           $.ajax({
  29.             type: "POST",
  30.             url: "login.php",
  31.             data: "username="+username+"&pass="+password,
  32.             success: function(html) {
  33.             if(html=='true') {
  34.                 $('#add_err').html('Вы успешно вошли в аккаунт!');
  35.                 setTimeout("window.location='ok.php';",1000);
  36.             }
  37.             else {
  38.                 $("#add_err").css('display', 'inline', 'important');
  39.                 $("#add_err").html("<img style='width:32;' src='alert.png'>Неверный Логин или Пароль!");
  40.             }
  41.            },
  42.            beforeSend:function() {
  43.                 $("#add_err").css('display', 'inline', 'important');
  44.                 $("#add_err").html("<img src='ajax-loader.gif'>Загрузка...")
  45.            }
  46.           });
  47.         return false;
  48.     });
  49. });
  50.    
  51. <?php
  52. require_once 'config.php';
  53. session_start();
  54.  
  55. if (isset($_POST['sick']) == 'doc') {
  56. $uName = $_POST['username'];
  57. $pWord = $_POST['pass'];
  58. $qry = "SELECT userid, username FROM usermetaDOCTOR WHERE username='".$uName."' AND pass='".$pWord."'  ";
  59. $res = mysql_query($qry);
  60. $num_row = mysql_num_rows($res);
  61. $row=mysql_fetch_assoc($res);
  62. if($num_row == 1) {
  63.     echo 'true';
  64.     $_SESSION['uName'] = $row['username'];
  65.     $_SESSION['oId'] = $row['orgid'];
  66.     }
  67.     else {
  68.         echo 'false';
  69.     }
  70. }
  71. else {
  72. $uName = $_POST['username'];
  73. $pWord = $_POST['pass'];
  74. $qry = "SELECT userid, username FROM usermetaPACIENT WHERE username='".$uName."' AND pass='".$pWord."'  ";
  75. $res = mysql_query($qry);
  76. $num_row = mysql_num_rows($res);
  77. $row=mysql_fetch_assoc($res);
  78. if($num_row == 1) {
  79.     echo 'true';
  80.     $_SESSION['uName'] = $row['username'];
  81.     $_SESSION['oId'] = $row['orgid'];
  82.     }
  83.     else {
  84.         echo 'false';
  85.     }
  86. }
  87. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top