A form submission handler can only print a message using drupal_set_message()
, or writing a message in the log with watchdog()
.
The alternative is saving the necessary data in the session, and redirect the user (using $form_state['redirect'] = 'page path';
) to a page where the content of the session is shown.
function firstmodule_menu() {
$items['the path for your page'] = array(
'page callback' => 'firstmodule_show_submitted_data';
// ...
);
return $items;
}
function firstmodule_form1_submit($form, &$form_state) {
$_SESSION['firstmodule_username'] = $username;
// ...
$form_state['redirect'] = 'the path for your page';
}
function firstmodule_show_submitted_data() {
// Populate $result with the string to show.
return $result;
}
As side note, the first argument of t()
must be a literal string, not a string obtained concatenating two strings, as in your case. You should use placeholders, as in the following code.
drupal_set_message(t("The user is %username", array('%username' => $username)));
In Drupal 7, instead of returning a string, you can return a render array.