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 trialMUZ140970 Shaune Muringani
11,962 PointsIn 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
<?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
Unsubscribed User
48,988 Points$user_age = $form_state['values']['age'];
MUZ140970 Shaune Muringani
11,962 Points@ julian i am still stuck hey its the last stage of dupral that i cannot get over ....please help!!!
Julian Aramburu
11,368 PointsHi! 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!
Benjamin Casalino
7,036 Pointsim stuck also :( has anyone else figured this out yet?!
Charles Russell
7,169 PointsWorked for me
$user_age = $form_state['values']['age'];