2
votes

I have created a reset password form in drupal 6. On submit I have to redirect to the same page show a Drupal message.

I have written the following:

  global $language;

  $account = $form_state['values']['account'];

  _user_mail_notify('password_reset', $account, $language);


  watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));

  drupal_set_message(t('Further instructions have been sent to your e-mail address.'));

  $form_state['redirect'] = 'user/password';
  return;

}

but my mail code is working fine but my message is not shown.

4
i think [this is the answer][1] you are looking for. [1]: stackoverflow.com/questions/1513289/…nit3ch

4 Answers

2
votes

Try this code it will redirect you on same page and show message...

$msg = "Further instructions have been sent to your e-mail address.";
drupal_set_message($msg, $type = 'status');
drupal_goto('user/password');
1
votes
  • Have you tried switching back to Garland (to check if the theme is at fault)?
  • Have you checked your user table has a 0 (zero) entry for anonymous? Sometimes imported tables miss that row due to the auto increment setting on the uid field.
  • Does the message show for authenticated/admin users?
  • I assume your snippet is the submit handler? I assume $form_state is being passed in by reference?
1
votes

You can try this code to redirect to another page with message

drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
drupal_goto('user/password');
1
votes

Instead of $form_state['redirect'] use the drupal_goto function:

drupal_set_message(
    'Further instructions have been sent to your e-mail address.',
     'status', $repeat = FALSE);
drupal_goto('user/password');