lamhottt

login.php

Aug 26th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1. <?php defined('sys_run_app') OR exit('403 You dont have permission to access / on this server...'); ?>
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6.     <title>Example Login | Tutorial Garuda Framework Pro</title>
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8. </head>
  9.     <?= _importJQuery(); ?>
  10.     <?= _importBootstrap(); ?>
  11.     <?= _importGF(); ?>
  12.     <?= _importSweetAlert(); ?>
  13. <body>
  14.    
  15.     <div class="container">
  16.       <hr>
  17.       <center><h2>Login </h2></center>
  18.        <hr>
  19.       <div class="well well-sm">
  20.             <center><a href="./forgot">FORGOT PASSWORD</a></center>
  21.       </div>
  22.      
  23.     </div>
  24.  
  25.     <div class="container">
  26.        
  27.         <div class="jumbotron">
  28.                 <div id="my_alert"></div>
  29.                 <input type="text" id="txt_email" class="form-control" name="" placeholder="Email..." required="">
  30.                 </br>
  31.                 <input type="password" id="txt_pass" class="form-control" name="" placeholder="New Password..." required="">
  32.                 </br>
  33.                 <input type="checkbox" name="" value="" id="my_check" > I Am Not Robot
  34.                 <hr>
  35.  
  36.                 <button id="btn_login" class="btn btn-primary">LOGIN</button>
  37.         </div>
  38.  
  39.     </div>
  40.  
  41.  
  42.     <script type="text/javascript">
  43.         $(document).ready(function(){
  44.                
  45.                 _focus("txt_email");
  46.  
  47.  
  48.                 _onClick("btn_login",function(){
  49.                     login();
  50.                 });
  51.  
  52.                
  53.  
  54.                 function login()
  55.                 {
  56.                     let email       = _getValById("txt_email");
  57.                     let pass        = _getValById("txt_pass");
  58.                     let my_check    = _getById("my_check");
  59.                     const token     = _randomStr(5);
  60.  
  61.                     if (email==='')
  62.                     {
  63.                         _writeAlert("my_alert","Upzz you have to type the email !","warning");
  64.                         _focus("txt_email");
  65.                         return;
  66.                     }
  67.  
  68.                     if (_checkEmail(email))
  69.                     {
  70.                        
  71.                         if (pass==='')
  72.                         {
  73.                             _focus("txt_pass");
  74.                             _writeAlert("my_alert","Upzz you have to type the new password !","warning");
  75.                             return;
  76.                         }
  77.                        
  78.                         if (my_check.checked==false)
  79.                         {
  80.                             _writeAlert("my_alert","Please Confirm You Are Not Robot","danger");
  81.                             return;
  82.                         }
  83.                        
  84.                         _printTo("my_alert","");
  85.                         btn_login.disabled=true;
  86.  
  87.                         // Ini ajax dengan POST Garuda Javascript
  88.                         _requestPOST("./process-login","token="+token
  89.                                                                 +"&email="+email
  90.                                                                 +"&pass="+pass+"",function(res){
  91.                                
  92.                                 if (res)
  93.                                 {
  94.                                     const obj = JSON.parse(res);
  95.                                     if (obj)
  96.                                     {
  97.                                         let result = obj.result;
  98.  
  99.                                        
  100.                                         if (result==='F')
  101.                                         {
  102.                                             swal("Upzz !","Email or Password is wrong !","error");
  103.                                             _focus("txt_email");
  104.                                         }
  105.                                         else if (result==='T')
  106.                                         {
  107.                                             _refresh(_myUrl()+"welcome");
  108.                                         }
  109.                                     }
  110.                                 }
  111.                                 btn_login.disabled=false;
  112.                                 my_check.checked =false;
  113.                         });
  114.                     }
  115.                     else
  116.                     {
  117.                         _writeAlert("my_alert","Upzz your email is not valid !","danger");
  118.                         _focus("txt_email");
  119.                         return;
  120.                     }
  121.  
  122.                
  123.                 }
  124.  
  125.                 // ini untuk custom keyboard saat menekan tombol INSERT
  126.                 _keyCustom(function(){
  127.                     login();
  128.                 },_keyCode.insert);
  129.                
  130.         });
  131.        
  132.     </script>
  133.  
  134. </body>
  135. </html>
Add Comment
Please, Sign In to add comment