hi,

i installed the form module and worked out this code. Its is supposed to take in username and email and print them out. i created this code

-----------

$form['user']["name"] = array(
'#type' => 'textfield',
'#title' => t('user_name'),
'#default_value' => 'crashpoint',
'#size' => 30,
'#maxlength' => 30,
'#description' => 'enter the username',
'#attributes' => NULL,
'#required' => TRUE,
);
$form['user']["email"] = array (
'#type' => 'textfield',
'#title' => t('email'),
'#default_value' => 'crashpoint@gmail.com',
'#size' => 20,
'#maxlength' => 20,
'#description' => 'enter the email',
'#attributes' => NULL,
'#required' => TRUE,
);
 
$form['submit_button'] = array(
      '#type' => 'submit',
    '#value' => t('Submit'),
    );

$output = drupal_get_form('create_form', $form);
print $output;

----------

This prints the form. But how do I go about printing the values that this form passes in the post array. I saw that the $_POST['edit'] array was used

So to the above snippet I added the lines
------------------

print "<br/><br/>";
$op = $_POST['edit'];
print "email is ".$op["email"]."<br/>";

------------

but it does not show any output. Can anyone please point out where am i going wrong?

Comments

amnon’s picture

but it does not show any output

because, when drupal_get_form() detects that the form was submitted (that is, that there's something in $_POST), it calls the form's callback function (create_form_submit(), which doesn't exist). THEN, it redirects the browser to the same URL, so the POST data gets cleared. It's by design (a good one!), it's not a bug.

You asked your question three days ago, so I won't elaborate. If you want a more detailed explanation, please reply.