1

I would like to create a multi-step user registration form in Drupal 6. The form_alter details are below

function caubo_registration_form_alter(&$form, &$form_state, $form_id) {
if ($form_id != "user_register") return;
 if (isset($form_state['storage']['page']) && $form_state['storage']['page'] == 2) {   
caubo_register_page_two($form, $form_state);
return;
}
$form['submit']['#value'] = "Next"; 
$form['#submit'] = array('caubo_register_form_submit');
return; 
}

// Second page of registration
function caubo_register_page_two(&$form, &$form_state) {
  $form['company_name'] = array(
'#type' => 'textfield',
'#required' => 1,
'#title' => 'Company Name',
'#default_value' => '',
'#size' => 50,
'#maxlength' => 50,
);
  $form_state['storage']['page'] = 3;
return $form;
}

function caubo_register_form_submit($form, &$form_state) {
switch ($form_state['storage']['page']) {
case 0:

  $form_state['rebuild'] = TRUE;
  $form_state['storage']['page'] = 2;                  
  $form_state['storage']['page_one_values'] = $form_state['values'];  
  break;

case 3:   // This is form submission, insert into Database
  insert_values($form, $form_state); 
  break;
}

function insert_values(&$form, &$form_state){
$insert = "INSERT INTO user_detail_values SET
            mlm_plan='binary',
            user_name='admin'";
$result = db_query($insert); 
}

But in the last step the function insert_values() is not called, the submitted data's not inserting into the database. I have searched in google, but i didn't get the solution. How to fix it ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.