Hi, I am new in Drupal module development.
I am trying to make a login system that looks like the one on drupal forum. I have used the form API and I want to display the login form with the hook_menu() function so that it shows in a page. But the page could not be found, This is what I have done:

<?php

// $Id$

/**
* @file
* Module for showing Login system form and display it through a URL or path.
*/

/**
* First I create a menu to display the login form
* Implements hook_menu() to create a URL for the login form.
*/
function user_menu() {
$items['userlogin'] = array(
'title' => t('Login System'),
'page callback' => 'drupal_get_form',
'page arguments' => array('user_login'),
'access callback' => TRUE,
);
return $items;
}

/**
* use hook_login() to display the login form
*
*
*/
function user_login($form, &$form_state) {
global $user;

// If already logged on, go to the user page instead.
if ($user->uid) {
drupal_goto('user/' . $user->uid);
}

// Display login form:
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Dispaly Name'),
'#size' => 60,
'#maxlength' => USERNAME_MAX_LENGTH,
'#required' => TRUE,
);

$form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
$form['pass'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#description' => t('Enter password.'),
'#required' => TRUE,
);
$form['#validate'] = user_login_default_validators();
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Log in'),
);

return $form;
}

I have named the module: user.module
Is there something I am not doing right?

Comments

Core already includes a

Core already includes a user.module which already provides both a login page (user/login) and block.

On top of that, it's usually

On top of that, it's usually better to alter existing forms than to recreate them. If you alter an existing form you get all the submission and validation that comes with the original form, rather than having to create it from scratch.

Jaypan We build websites

Re

Thanks for the reply.

nobody click here