Hi,

i got this really strange beginners problem. I want to use a form and then capture and store variables from it. But i can never capture forms variable althou they can be seen with print_r function. Please help me to capture it.

Here is the code i use for form generation:

 //form for variable setting.
 $forma[urly] = array(
 '#type' => 'textfield',
 '#title' => t('Enter Yahoo news URL'),
 '#default_value' => 'http://www.yahoo.org/',
 '#maxlenght' => '333',
 );
 $forma['submit'] = array('#type' => 'submit', '#value' => t('Save new settings.'));

 //let's add this form to output
 $output .= drupal_get_form('my_form', $forma);

and above it i try to capture $_POST[edit][urly] with this code:
//$output .= '<code>' . print_r ($_POST) . ''; //debug line
$output .= 'XX'. $_POST['edit']['urly'] . 'XX'; //debug line
variable_set('importNewsURLyahoo',$_POST['edit']['urly']);
$output .= variable_get('importNewsURLyahoo','Variable never been set before.');

print_r if uncommented shows:

Array
(
    [edit] => Array
        (
            [urly] => http://www.yahoo.org/dcsd
            [form_id] => my_form
        )

    [op] => Save new settings.
)

Please tell me how to access that urly field variable.

Thank you and sorry if it's more PHP than drupal related problem ;-)

Comments

hexa’s picture

Now i just found out that i DO get the data from that form into:
$_POST['edit']['urly'];
as expected. And if i echo it, it works.

Now i'm going to open a new forum thread for theme() function since it doesn't display that ($urly=$_POST['edit']['urly'];) variable contents.

New thread is here ;-)
http://drupal.org/node/73330