Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function login_theme()
- {
- return array(
- 'login_form' => array(
- 'render element' => 'form',
- 'path' => drupal_get_path('module', 'login'),
- 'template' => 'login-form',
- )
- );
- }
- function login_menu()
- {
- $items = array();
- $items['cms/login'] = array(
- 'title' => 'CMS Login',
- 'description' => 'Interface untuk login CMS',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('login_form'),
- 'access callback' => TRUE
- //'access arguments' => array('access content')
- //'type' => MENU_CALLBACK,
- //'access callback' => 'login_form_access'
- );
- return $items;
- }
- function login_help($path, $arg)
- {
- switch($path)
- {
- case "admin/help#login":
- return "Modul untuk menampilkan interface login CMS.";
- break;
- }
- }
- function login_form($form, &$form_state)
- {
- $form['username'] = array(
- '#type' => 'textfield',
- '#title' => 'Username',
- '#required' => TRUE
- );
- $form['password'] = array(
- '#type' => 'password',
- '#title' => 'Password',
- '#required' => TRUE
- );
- $form['submit_button'] = array(
- '#type' => 'submit',
- '#value' => 'Login'
- );
- return $form;
- }
- function login_form_validate($form, &$form_state)
- {
- }
- function login_form_submit($form, &$form_state)
- {
- $pesan = '';
- try
- {
- $hasil = db_query(
- "select * from sys_userlis
- where
- username = :username AND
- password = :password
- ",
- array(
- ':username' => $form_state['values']['username'],
- ':password' => sha1($form_state['values']['password'])
- )
- );
- if($hasil->rowCount() > 0)
- {
- while($baris = $hasil->fetchAssoc())
- {
- $pesan = 'Berhasil login';
- }
- }
- else
- {
- $pesan = "Hasil query kosong";
- }
- }
- catch(Exception $e)
- {
- $pesan = "Exception $e";
- }
- drupal_set_message($pesan);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement