Hello,

I have a problem with one of my module what I can't understand at all.
The module worked properly under Drupal 6 but now when I re-write it to D7 it doesn't want to work.
Now what I figured out the problem root is in the database handle.
Here is a peek:

    $id = db_insert('gft_demo')
    ->fields(array(
      'demoid' => $username,
      'first_name' => $form_state['values']['first_name'],
      'last_name' => $form_state['values']['last_name'],
      'country' => $form_state['values']['country'],
      'iskola' => $form_state['values']['iskola'],
      'email_address' => $form_state['values']['email_address'],
      'phone' => $form_state['values']['phone'],
      'initial_deposit' => $form_state['values']['initial_deposit'],
      'base_currency' => $form_state['values']['base_currency'],
      'username' => $username,
      'gft_timestamp' => date('o-m-d h:i:s'),
    ))
    ->execute();

If I use my module without this section It's working well, but I need to store these data in the DB, so any help would be great.

I doesn't get any error msg.

Any idea?

Thanks a lot,

David

Comments

What's the problem?

What's the problem?

Jaypan We build websites

The problem

I got no error msg.
I doesn't have any new database row.
The form post breaking , and I doesn't have a redirect.
Here is the full code:

function my_module_openform_submit($form, &$form_state) {
   
  $cs = curl_init('http://demo.gftforex.com:8080/registrator/servlet/gft.util.registrator.Registrator');
  curl_setopt($cs, CURLOPT_POST, 1);
  curl_setopt($cs, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($cs, CURLOPT_HEADER, true); // tells curl to include headers in response
  curl_setopt($cs, CURLOPT_POSTFIELDS,
  "can_trade=cfd" .
  "&who=FXFlat" .
  "&first_name=" . htmlspecialchars($form_state['values']['first_name']) .
  "&last_name=" . htmlspecialchars($form_state['values']['last_name']) .
  "&PASSWORD=" . htmlspecialchars($form_state['values']['password']) .
  "&country=" . htmlspecialchars($form_state['values']['country']) .
  "&email_address=" . htmlspecialchars($form_state['values']['email_address']) .
  "&initial_deposit=" . htmlspecialchars($form_state['values']['initial_deposit']) .
  "&base_currency=" . htmlspecialchars($form_state['values']['base_currency']) .
  "&groups=" . htmlspecialchars("GFTUK Gold Forex Trading") .
  "&Message=");
  //curl_setopt ($cs, CURLOPT_FOLLOWLOCATION, 1);
  $result = curl_exec($cs);
  $headers = curl_getinfo($cs);

  if ($headers['http_code'] != '302') {
    drupal_set_message(t('Communication with server failed'));
  }
  else {
    // "User-Id: " header
    preg_match('/User-Id: ([\w]*)/', $result, $m);
    $username = $m[1];
    curl_close($cs);
   
     // Sending notification e-mail to the user
     _user_demo_email(
      $form_state['values']['email_address'],
      $username,
      $form_state['values']['password']);

    // Sending notification e-mail to the site admins
    _admin_demo_email(
      $username,
      $form_state['values']['email_address'],
      $form_state['values']['phone'],
      $form_state['values']['first_name'] . ' ' . $form_state['values']['last_name'],
      $form_state['values']['initial_deposit'] . $form_state['values']['base_currency']
    );
   
    // Insert the reg data to the DB
    $id = db_insert('gft_demo')
    ->fields(array(
      'demoid' => $username,
      'first_name' => $form_state['values']['first_name'],
      'last_name' => $form_state['values']['last_name'],
      'country' => $form_state['values']['country'],
      'iskola' => $form_state['values']['iskola'],
      'email_address' => $form_state['values']['email_address'],
      'phone' => $form_state['values']['phone'],
      'initial_deposit' => $form_state['values']['initial_deposit'],
      'base_currency' => $form_state['values']['base_currency'],
      'username' => $username,
      'gft_timestamp' => date('o-m-d h:i:s'),
    ))
    ->execute();

    // Redirect to the Thank you page
    $form_state['redirect'] = 'node/61';
  }
}

So after I submit the form, the site doesn't do anything. It doesn't insert data to the db, doesn't send the mails. Simply do nothing.

If I cut out the db insert section the code working well. Sending the mails and redirect to the Thank you node.

No errors in the log table.

Try using

Try using drupal_http_request() instead of curl functions.

Jaypan We build websites

Solved

Thankxós dor te help, but the problem solved in different way. The problem was in the database. The table somehow went to crazy... I delete it and recreate it again and now everything works fine.

nobody click here