hi every one! I am new to drupal. I have created module with name contace1 code is below:-
contace1.info
; $Id$
name = Contact1
description = Show how to build contact form
package = Pro Drupal Development
core = 6.x
and contact1.module
<?php
// $Id$
/**
* @file
* practice to build form
*/
/**
* Implimentation of hook_menue().
*/
function contact_menu()
{
$items['contact1'] = array(
'title' => 'Contact',
'page callback' => 'contact_page',
'access argument' => array('access content'),
'type'=>MENU_CALL_BACK,
'access callback' => TRUE,
);
return $items;
}
/**
* menu callback
* called when user goes to http://localhost/drupaldemo/?q=contact
*/
function contact_page()
{
$output = t('You can leave a message using the contact form below.');
//Return the html generated from $form data structure.
$output.= drupal_get_form('contact_nameform');
return $output;
}
/**
* define the form
*/
function contact_nameform()
{
$form['user_name']= array(
'#title' =>t('Your Name'),
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
) ;
return $form;
}
/**
* validate the form
**/
function contact_nameform_validate()
{
if($form_state['values']['user_name']=="")
{
form_set_error('user_name',t('Please enter your name.'));
}
}
/**
* handle post validation form submition
*/
function contact_nameform_submit($form ,&$form_state)
{
$name=$form_state['values']['user_name'];
drupal_set_message(t('Thanks for filling out the form, %name',array('%name'=>$name)));
}
im this code i have tried to create new contact form
but it does not show any link and on opening page directly give page not found