hi,
i doubt whether this is possible , if it is possible i ll be delighted . I have a form of php array , with a submit button passing the values , this submit button is so ordinary , so i want to change the look and feel of button , where i have a button image for it , but i cant fix it , ths submit button in php is this,

$form['submit'] = array('#type' => 'submit', '#value' => t('Create Account'), '#weight' => 40);

Thank you !!!

you do this by adding an image tag

<img src="whatever.jpg or png etc" id="whatever" onclick="dosomething();"/>

This is the easiest way of doing it and I use it in various forms.

to pass the array information you can echo it within the () of the function that is called by the onclick.

hi ,
thanks for your reply , i tried the following with your guideline ,

$form['submit'] = array('#type' => 'submit', '#value' => t('Make Payment'), '#weight' => 40, <img src = 'sites/all/themes/MathsLeaderTheme/images/submit_up.gif' />  );
   
 $form['#validate'][] = 'user_register_validate';
   return $form;

but it return parse error ....am just starting out in php , so please correct me if i made silly mistakes....

Thank you !!

you do this by adding an image tag

<img src="whatever.jpg or png etc" id="whatever" onclick="dosomething();"/>

This is the easiest way of doing it and I use it in various forms.

to pass the array information you can echo it within the () of the function that is called by the onclick.

What are you using to generate the forms?

Just a guess here, but by looking at the formatting you could probably do:

$form['submit'] = array('#type' => 'image', '#src'=>'sites/all/themes/MathsLeaderTheme/images/submit_up.gif'  );

hi ,
i tried your code of line , but not displaying anything in the page . Am working in drupal this line is from user registration page , the entire code is :

define('USERNAME_MAX_LENGTH', 10);
define('EMAIL_MAX_LENGTH', 10);

function user_register_submit($form, &$form_state) {
  global $base_url;
  $admin = user_access('administer users');

  $mail = $form_state['values']['mail'];
  $name = $form_state['values']['name'];
  if (!variable_get('user_email_verification', TRUE) || $admin) {
    $pass = $form_state['values']['pass'];
  }
  else {
    $pass = user_password();
  };
  $notify = isset($form_state['values']['notify']) ? $form_state['values']['notify'] : NULL;
  $from = variable_get('site_mail', ini_get('sendmail_from'));
  if (isset($form_state['values']['roles'])) {
    // Remove unset roles.
    $roles = array_filter($form_state['values']['roles']);
  }
  else {
    $roles = array();
  }

  if (!$admin && array_intersect(array_keys($form_state['values']), array('uid', 'roles', 'init', 'session', 'status'))) {
    watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
    $form_state['redirect'] = 'user/register';
    return;
  }
  // The unset below is needed to prevent these form values from being saved as
  // user data.
  unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination']);

  $merge_data = array('pass' => $pass, 'init' => $mail, 'roles' => $roles);
  if (!$admin) {
    // Set the user's status because it was not displayed in the form.
    $merge_data['status'] = variable_get('user_register', 1) == 1;
  }
  $account = user_save('', array_merge($form_state['values'], $merge_data));
  // Terminate if an error occured during user_save().
  if (!$account) {
    drupal_set_message(t("Error saving user account."), 'error');
    $form_state['redirect'] = '';
    return;
  }
  $form_state['user'] = $account;

  watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));

  // The first user may login immediately, and receives a customized welcome e-mail.
  if ($account->uid == 1) {
    drupal_set_message(t('Welcome to Drupal. You are now logged in as user #1, which gives you full control over your website.'));
    if (variable_get('user_email_verification', TRUE)) {
      drupal_set_message(t('</p><p> Your password is <strong>%pass</strong>. You may change your password below.</p>', array('%pass' => $pass)));
    }

    user_authenticate(array_merge($form_state['values'], $merge_data));

    $form_state['redirect'] = 'user/1/edit';
    return;
  }
  else {
    // Add plain text password into user account to generate mail tokens.
    $account->password = $pass;
    if ($admin && !$notify) {
      drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
    }
    else if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
      // No e-mail verification is required, create new user account, and login
      // user immediately.
      _user_mail_notify('register_no_approval_required', $account);
      if (user_authenticate(array_merge($form_state['values'], $merge_data))) {
        drupal_set_message(t('Registration successful. You are now logged in.'));
      }
      $form_state['redirect'] = '';
      return;
    }
    else if ($account->status || $notify) {
      // Create new user account, no administrator approval required.
      $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
      _user_mail_notify($op, $account);
      if ($notify) {
        drupal_set_message(t('Password and further instructions have been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
      }
      else {
        drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
        $form_state['redirect'] = '';
        return;
      }
    }
    else {
      // Create new user account, administrator approval required.
      _user_mail_notify('register_pending_approval', $account);
      drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
      $form_state['redirect'] = '';
      return;

    }
  }
    
	
}

/**
 * Form builder; The user registration form.
 *
 * @ingroup forms
 * @see user_register_validate()
 * @see user_register_submit()
 */
function user_register() {
  global $user;

  $admin = user_access('administer users');

  // If we aren't admin but already logged on, go to the user page instead.
  if (!$admin && $user->uid) {
    drupal_goto('user/'. $user->uid);
  }

  $form = array();

  // Display the registration form.
  if (!$admin) {
    $form['user_registration_help'] = array('#value' => filter_xss_admin(variable_get('user_registration_help', '')));
  }

  // Merge in the default user edit fields.
  $form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));
  if ($admin) {
    $form['account']['notify'] = array(
     '#type' => 'checkbox',
     '#title' => t('Notify user of new account')
    );
    // Redirect back to page which initiated the create request;
    // usually admin/user/user/create.
    $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
  }

  // Create a dummy variable for pass-by-reference parameters.
  $null = NULL;
  $extra = _user_forms($null, NULL, NULL, 'register');

  // Remove form_group around default fields if there are no other groups.
  if (!$extra) {
    foreach (array('name', 'mail', 'pass', 'status', 'roles', 'notify') as $key) {
      if (isset($form['account'][$key])) {
        $form[$key] = $form['account'][$key];
      }
    }
    unset($form['account']);
  }
  else {
    $form = array_merge($form, $extra);
  }

  if (variable_get('configurable_timezones', 1)) {
    // Override field ID, so we only change timezone on user registration,
    // and never touch it on user edit pages.
    $form['timezone'] = array(
      '#type' => 'hidden',
      '#default_value' => variable_get('date_default_timezone', NULL),
      '#id' => 'edit-user-register-timezone',
    );

    // Add the JavaScript callback to automatically set the timezone.
    drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.setDefaultTimezone();
  });
}', 'inline');
  }

 [B]// $form['submit'] = array('#type' => 'submit', '#value' => t('Make Payment'), '#weight' => 40,  );
 
 $form['submit'] = array('#type' => 'image', '#src'=>'sites/all/themes/MathsLeaderTheme/images/submit_up.gif'  );
 [/B]
  
     
 $form['#validate'][] = 'user_register_validate';
 
 
  return $form;
  
}

function user_register_validate($form, &$form_state) {
  user_module_invoke('validate', $form_state['values'], $form_state['values'], 'account');
  
}

 // Registration and login pages.
  $items['user'] = array(
    'title' => 'User account',
    'page callback' => 'user_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'user.pages.inc',
  );

  $items['user/login'] = array(
    'title' => 'Log in',
    'access callback' => 'user_is_anonymous',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );

  $items['user/register'] = array(
    'title' => 'Create new account',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_register'),
    'access callback' => 'user_register_access',
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
  );

please help me out

thank you !!!!!!!!

hi ,
i tried your code of line , but not displaying anything in the page . Am working in drupal this line is from user registration page , the entire code is :

define('USERNAME_MAX_LENGTH', 10);
define('EMAIL_MAX_LENGTH', 10);

function user_register_submit($form, &$form_state) {
global $base_url;
$admin = user_access('administer users');

$mail = $form_state['values']['mail'];
$name = $form_state['values']['name'];
if (!variable_get('user_email_verification', TRUE) || $admin) {
$pass = $form_state['values']['pass'];
}
else {
$pass = user_password();
};
$notify = isset($form_state['values']['notify']) ? $form_state['values']['notify'] : NULL;
$from = variable_get('site_mail', ini_get('sendmail_from'));
if (isset($form_state['values']['roles'])) {
// Remove unset roles.
$roles = array_filter($form_state['values']['roles']);
}
else {
$roles = array();
}

if (!$admin && array_intersect(array_keys($form_state['values']), array('uid', 'roles', 'init', 'session', 'status'))) {
watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
$form_state['redirect'] = 'user/register';
return;
}
// The unset below is needed to prevent these form values from being saved as
// user data.
unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination']);

$merge_data = array('pass' => $pass, 'init' => $mail, 'roles' => $roles);
if (!$admin) {
// Set the user's status because it was not displayed in the form.
$merge_data['status'] = variable_get('user_register', 1) == 1;
}
$account = user_save('', array_merge($form_state['values'], $merge_data));
// Terminate if an error occured during user_save().
if (!$account) {
drupal_set_message(t("Error saving user account."), 'error');
$form_state['redirect'] = '';
return;
}
$form_state['user'] = $account;

watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));

// The first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) {
drupal_set_message(t('Welcome to Drupal. You are now logged in as user #1, which gives you full control over your website.'));
if (variable_get('user_email_verification', TRUE)) {
drupal_set_message(t('</p><p> Your password is <strong>%pass</strong>. You may change your password below.</p>', array('%pass' => $pass)));
}

user_authenticate(array_merge($form_state['values'], $merge_data));

$form_state['redirect'] = 'user/1/edit';
return;
}
else {
// Add plain text password into user account to generate mail tokens.
$account->password = $pass;
if ($admin && !$notify) {
drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
}
else if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
// No e-mail verification is required, create new user account, and login
// user immediately.
_user_mail_notify('register_no_approval_required', $account);
if (user_authenticate(array_merge($form_state['values'], $merge_data))) {
drupal_set_message(t('Registration successful. You are now logged in.'));
}
$form_state['redirect'] = '';
return;
}
else if ($account->status || $notify) {
// Create new user account, no administrator approval required.
$op = $notify ? 'register_admin_created' : 'register_no_approval_required';
_user_mail_notify($op, $account);
if ($notify) {
drupal_set_message(t('Password and further instructions have been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
}
else {
drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
$form_state['redirect'] = '';
return;
}
}
else {
// Create new user account, administrator approval required.
_user_mail_notify('register_pending_approval', $account);
drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
$form_state['redirect'] = '';
return;

}
}


}

/**
* Form builder; The user registration form.
*
* @ingroup forms
* @see user_register_validate()
* @see user_register_submit()
*/
function user_register() {
global $user;

$admin = user_access('administer users');

// If we aren't admin but already logged on, go to the user page instead.
if (!$admin && $user->uid) {
drupal_goto('user/'. $user->uid);
}

$form = array();

// Display the registration form.
if (!$admin) {
$form['user_registration_help'] = array('#value' => filter_xss_admin(variable_get('user_registration_help', '')));
}

// Merge in the default user edit fields.
$form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));
if ($admin) {
$form['account']['notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify user of new account')
);
// Redirect back to page which initiated the create request;
// usually admin/user/user/create.
$form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
}

// Create a dummy variable for pass-by-reference parameters.
$null = NULL;
$extra = _user_forms($null, NULL, NULL, 'register');

// Remove form_group around default fields if there are no other groups.
if (!$extra) {
foreach (array('name', 'mail', 'pass', 'status', 'roles', 'notify') as $key) {
if (isset($form['account'][$key])) {
$form[$key] = $form['account'][$key];
}
}
unset($form['account']);
}
else {
$form = array_merge($form, $extra);
}

if (variable_get('configurable_timezones', 1)) {
// Override field ID, so we only change timezone on user registration,
// and never touch it on user edit pages.
$form['timezone'] = array(
'#type' => 'hidden',
'#default_value' => variable_get('date_default_timezone', NULL),
'#id' => 'edit-user-register-timezone',
);

// Add the JavaScript callback to automatically set the timezone.
drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
$(document).ready(function() {
Drupal.setDefaultTimezone();
});
}', 'inline');
}

[B]// $form['submit'] = array('#type' => 'submit', '#value' => t('Make Payment'), '#weight' => 40, );

$form['submit'] = array('#type' => 'image', '#src'=>'sites/all/themes/MathsLeaderTheme/images/submit_up.gif' );
[/B]


$form['#validate'][] = 'user_register_validate';


return $form;

}

function user_register_validate($form, &$form_state) {
user_module_invoke('validate', $form_state['values'], $form_state['values'], 'account');

}

// Registration and login pages.
$items['user'] = array(
'title' => 'User account',
'page callback' => 'user_page',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'user.pages.inc',
);

$items['user/login'] = array(
'title' => 'Log in',
'access callback' => 'user_is_anonymous',
'type' => MENU_DEFAULT_LOCAL_TASK,
);

$items['user/register'] = array(
'title' => 'Create new account',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_register'),
'access callback' => 'user_register_access',
'type' => MENU_LOCAL_TASK,
'file' => 'user.pages.inc',
);

please help me out

thank you !!!!!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.