Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Drupal Basics Writing Modules Drupal Modules Review

In the my_profile_form_submit function, assign the user's age from the form to the $user_age variable. i am failing....

can anyone help me out here the question sound s so vague

my_profile.module
<?php

function my_profile_form() {
    $form = array();
    $form['age'] = array(
        '#title' => 'Age',
        '#type' => 'textfield',
        '#description' => t('Please enter your age.'),
    );    
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Go',
    );
    return $form;
}

function my_profile_form_submit($form, &$form_state) {

    $user_age =$form_state['Go'];

    $_SESSION['age'] = $user_age;  
    $form_state['redirect'] = 'created';
}

5 Answers

$user_age = $form_state['values']['age'];

@ julian i am still stuck hey its the last stage of dupral that i cannot get over ....please help!!!

Julian Aramburu
Julian Aramburu
11,368 Points

Hi! I think you should use $form_state to access the variable value you need and assign it to $user_age :)!

Hopes it help you out!

Cheers!

im stuck also :( has anyone else figured this out yet?!

Charles Russell
Charles Russell
7,169 Points

Worked for me

$user_age = $form_state['values']['age'];