Add additional button to login form Drupal 7


I am trying to add a new button or link to my log in form. The button would simply link to another page outside of the drupal framework. I am looking at the form_alter hook but I am not sure if I completely understand how to implement my update.

do I have to update the template.php page?

The form is the login form on the front page. Any help would be great.

I am pretty sure I need something like the following :

&lt;?php
$form['preview'] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; t('Preview'),
  '#weight' =&gt; 19,
);
?&gt;


But I need to add the link. request.php to the button so when clicked it will go to request.php. Also I am not sure where to add this code and how to direct it to my log in form.
You cannot alter a form from a theme's template.php file. You need to create a custom module for that. In this module, you can alter the login form in an implementation of the hook_form_alter() or hook_form_FORM_ID_alter() hooks.

Without some JavaScript, you will not be able to submit the form to a separated URL. What you can do, in your module, is to provide an dedicated validation or submit handler for you button. In this handler, you can redirect to your external URL using drupal_goto().

Something like:

MODULE_form_user_login_alter(&amp;$form, &amp;$form_state) {
  $form['foo'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; t('Foo'),
    '#submit' =&gt; array('MODULE_user_login_foo_submit'),
    '#limit_validation_errors' =&gt; array(),
  );
}

MODULE_user_login_foo_submit($form, &amp;$form_state) {
  drupal_goto('/path/to/request.php', array('external' =&gt; TRUE));
}