Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. <?php
  2.  
  3. function login_theme()
  4. {
  5. return array(
  6. 'login_form' => array(
  7. 'render element' => 'form',
  8. 'path' => drupal_get_path('module', 'login'),
  9. 'template' => 'login-form',
  10. )
  11. );
  12. }
  13.  
  14. function login_menu()
  15. {
  16. $items = array();
  17.  
  18. $items['cms/login'] = array(
  19. 'title' => 'CMS Login',
  20. 'description' => 'Interface untuk login CMS',
  21. 'page callback' => 'drupal_get_form',
  22. 'page arguments' => array('login_form'),
  23. 'access callback' => TRUE
  24.  
  25. //'access arguments' => array('access content')
  26. //'type' => MENU_CALLBACK,
  27. //'access callback' => 'login_form_access'
  28.  
  29.  
  30. );
  31.  
  32. return $items;
  33. }
  34.  
  35. function login_help($path, $arg)
  36. {
  37. switch($path)
  38. {
  39. case "admin/help#login":
  40. return "Modul untuk menampilkan interface login CMS.";
  41. break;
  42. }
  43. }
  44.  
  45. function login_form($form, &$form_state)
  46. {
  47. $form['username'] = array(
  48. '#type' => 'textfield',
  49. '#title' => 'Username',
  50. '#required' => TRUE
  51. );
  52.  
  53. $form['password'] = array(
  54. '#type' => 'password',
  55. '#title' => 'Password',
  56. '#required' => TRUE
  57. );
  58.  
  59. $form['submit_button'] = array(
  60. '#type' => 'submit',
  61. '#value' => 'Login'
  62. );
  63.  
  64. return $form;
  65. }
  66.  
  67. function login_form_validate($form, &$form_state)
  68. {
  69. }
  70.  
  71. function login_form_submit($form, &$form_state)
  72. {
  73. $pesan = '';
  74.  
  75. try
  76. {
  77.  
  78. $hasil = db_query(
  79. "select * from sys_userlis
  80. where
  81. username = :username AND
  82. password = :password
  83. ",
  84. array(
  85. ':username' => $form_state['values']['username'],
  86. ':password' => sha1($form_state['values']['password'])
  87. )
  88. );
  89.  
  90. if($hasil->rowCount() > 0)
  91. {
  92.  
  93. while($baris = $hasil->fetchAssoc())
  94. {
  95.  
  96. $pesan = 'Berhasil login';
  97. }
  98. }
  99. else
  100. {
  101. $pesan = "Hasil query kosong";
  102. }
  103.  
  104. }
  105. catch(Exception $e)
  106. {
  107. $pesan = "Exception $e";
  108. }
  109.  
  110. drupal_set_message($pesan);
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement