How to create a form on a new page? I'm new to Drupal. What I'd like to do is create a form on a new page, having full control over the css/html of the form, and post the form to PHP for processing. The PHP should do some custom things to the form data, dump some stuff to the DB, return some stuff from the DB, and either redirect to a new page or return an error. No need to go into details about the PHP/DB stuff - just need to figure out how to go about creating a new page, and where to post the form to for processing. Should be able to figure everything else out from there!
To create a form on a page you need to use Drupal's Form API. It seems a bit complex at the first sight, but it isn't as it seems.

The steps you need to follow:


Create a custom module
Implement hook_menu() in your module and set a path for your page which should render the form.
A form builder function that builds a form using the Form API.


An Example for hook_menu() implementation:

function YOURMODULE_menu() {
  $items['some/path'] = array(
    'title' =&gt; 'My page title',
    'description' =&gt; 'An example page',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('YOURMODULE_example_form'),
  );
  return $items;
}


This code registers a paths as http://example.com/some/path and calls drupal_get_form() function, which gets a form with the given id, which in this example is YOURMODULE_example_form.

An example for the form builder function:

function YOURMODULE_example_form($form, &amp;$form_state) {
  $form['some_text_field'] = array(
    '#title' =&gt; t('Enter some text'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Send form'),
  );

  return $form;
}