Guest User

Untitled

a guest
Aug 18th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.65 KB | None | 0 0
  1. /********************* WEB INTERFACE *********************/
  2. <div id="dialog_login" title="Login">
  3.                     <form style="height: 100px;">
  4.                         <div>
  5.                             Username
  6.                         </div>
  7.                         <div>
  8.                             <input type="text" name="diabox_username" class="text ui-widget-content ui-corner-all" />
  9.                         </div>
  10.                         <div style="padding-top: 5px;">
  11.                             Password
  12.                         </div>
  13.                         <div>
  14.                             <span><input type="password" name="diabox_password" value="" class="text ui-widget-content ui-corner-all" /></span>
  15.                         </div>
  16.                         <div id="diabox_information">sdf</div>
  17.                     </form>
  18.                 </div>
  19.  
  20. /************* JQUERY *****************/
  21. <script type="text/javascript">
  22.             $(function(){
  23.                 $( "#dialog_login" ).dialog({
  24.                     autoOpen: false,
  25.                     height: 253,
  26.                     width: 250,
  27.                     resizable: true,
  28.                     draggable: false,
  29.                     modal: true,
  30.                     buttons: {
  31.                         "Login": function() {
  32.                             $data = "do=validateLogin";
  33.                             $data += "&username=" + $("#dialog_login input:[name=diabox_username]").val();
  34.                             $data += "&password=" + $("#dialog_login input:[name=diabox_password]").val();
  35.  
  36.                             $.ajax({
  37.                                 url: "/inc/user.bridge.php",
  38.                                 type: "POST",
  39.                                 data: $data,
  40.                                 success: function(msg){
  41.                                     alert(msg);
  42.                                     //$("#diabox_information").html(msg);
  43.                                 }
  44.                             });
  45.                         }
  46.                     }
  47.                 });
  48.  
  49.                 // Dialog Link
  50.                 $('#bt_login').click(function(){
  51.                     $('#dialog_login').dialog('open');
  52.                     return false;
  53.                 });
  54.             });
  55.  
  56.         </script>
  57. /*********** BRIDGE ****************/
  58. if ($_POST['do'] == "validateLogin")
  59.     {
  60.         echo "test";
  61.         /*$db_connection->connect();
  62.  
  63.         $username = $_POST['username'];
  64.         $password = $_POST['password'];
  65.  
  66.         $usertype = $user->checkLogin($username, $password);
  67.  
  68.         echo $usertype;
  69.  
  70.         switch($usertype)
  71.         {
  72.             case 1: //Tipe user 'EXPERT
  73.  
  74.                     break;
  75.             case 2: //Tipe user 'ADMIN'
  76.                     break;
  77.             case 3: //Tipe user 'CUSTOMER'
  78.                     echo "<script>window.location.href='/user/index.php'</script>";
  79.                     break;
  80.             default: echo "wrong username or password";
  81.         }
  82.  
  83.         $db_connection->disconnect();
  84.         */
  85.     }
  86.  
  87. /********************* PHP CLASS *********************/
  88. function checkLogin ($username, $password)
  89.     {
  90.         $this->query = "SELECT  user_type
  91.                         FROM    user
  92.                         WHERE   username = $username
  93.                         AND     password = $password;";
  94.         $this->result = mysql_query ($this->query);
  95.         $result = mysql_result($this->result, 0, 'user_type');
  96.  
  97.  
  98.         if ($this->result)      //Username tersebut ada
  99.             return $result;
  100.         else                    //Username tersebut ga ada
  101.             return 0;
  102.     }
Add Comment
Please, Sign In to add comment