I have no idea why my form submit only work if I put on screen values of $form argument.

If I add:

echo '<pre>';
echo '</pre>'

to my submit function I am getting new 'page' with this data printed out, but when I uncomment this nothing seems to work, I see form page again.

function gate_check_form_submit($form, &$form_state) {
    $post = $form['#post'];
//    echo '<pre>';
//    print_r($form);
//    echo '</pre>';
    echo '<pre>';
    print_r($post); //gives nothing
    echo '</pre>';

    $day = intval($post['gate_day']);
    $month = intval($post['gate_month']);
    $year = intval($post['gate_year']);
    $isRemember = isset($post['gate_remember_me']);
    if ($day && $month && $year) {
        $allowed_age = (int) variable_get('gate_minimal_age', 18);
        $min_born_time  = mktime(0, 0, 0, date("m"),   date("d"),   date("Y") - $allowed_age);
        $born_time = mktime(0, 0, 0, $month, $day, $year);
        echo '<pre>';
        echo '</pre>';
        echo '<pre>';
        echo '</pre>';
        if ($min_born_time >= $born_time) {
            echo 'yes';
           sess_write(GATE_SESSION_NAME, TRUE);
           if ($isRemember) {
               set_cookie(GATE_COOKIE_NAME, sha1($born_time + srand()), time()+60*60*24*7);

        echo 'no';
  • First, you should use echo "<pre>" . print_r($form,1) . "</pre>".
    – user334
    May 4, 2011 at 11:20
  • It does nothing
    – user1077
    May 4, 2011 at 11:39
  • 1
    I suggest you to use the devel module and the dpm function. dpm($form_values, 'form_values'); dpm($form, 'form');
    – user334
    May 4, 2011 at 12:43
  • You should not use sess_write() to write data in the session; it's enough you use $_SESSION[].
    – apaderno
    May 5, 2011 at 0:28

1 Answer 1


You are doing it wrong*. You should read the Form API quickstart guide to understand how to use the validate and submit handlers properly.

* For several reasons, the biggest one being that you are using #post, which is a big no-no. You should use sanitized values from $form_state['values'] instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.