Submit values and redirect user from to external URL What is the equivalence of:

   &lt;form action="https://paypaad.bankpasargad.com/PaymentController" method="POST"&gt;
            &lt;input type="hidden" name="content" value='&lt;?php echo $xml ?&gt;' /&gt;
            &lt;input type="hidden" name="sign" value="&lt;?php echo $sign ?&gt;" /&gt;
            &lt;input type="submit" value="send" name="submit" /&gt;
   &lt;/form&gt; 


in Drupal 7 ?

I already use following code in my form submit handler, but it doesn't work:

function Chargingform_nameform_submit($form, &amp;$form_state) 
   {
    $options = array();
    $options = array(
        'method' =&gt; 'POST',       
        'xml' =&gt; $form_state['values']['xml'],
        'sign' =&gt; $form_state['values']['sign'],
        'headers' =&gt; array('Content-Type' =&gt; 'application/x-www-form-urlencoded'),          
    );

   $url = 'https://paypaad.bankpasargad.com/PaymentController'; 
   $response = drupal_http_request($url, $options);
}


How I can submit XML, sign to URL and redirect user to that URL at the same time?

This is my code:

function Chargingform_nameform() {
    $xml = 'PHP Handbook30000130000This is good book.MySQL Handbook25000250000This is a good book too.';
    // Get sing
    $sign ='ewtnXYRWPSalHhna9hgO+Kc0W9Z8JBUeG1FkcKPvZL5w2s588c0/B9r';

    $form['xml'] = array(
       '#title' =&gt; t('xml'),
       '#type' =&gt;'hidden',
       '#value'=&gt;$xml,      
    );
    $form['sign'] = array(
       '#title' =&gt; t('sign'),
       '#type' =&gt;'hidden',
       '#value'=&gt;$sign,
    );   
    $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('submit'),
    );
    return $form;
}


function Chargingform_nameform_submit($form, &amp;$form_state) {  
  $options = array();   
  $options = array(
    'method' =&gt; 'POST',       
    'xml' =&gt; $form_state['values']['xml'],
    'sign' =&gt; $form_state['values']['sign'],            
  );    
  $url = 'https//:url';    
  $response = drupal_http_request($url, $options);   
}


I don't know really how to manage it in JavaScript.

Any suggestions?
You can generate form like that using '#type' =&gt; 'hidden' form API fields, and using '#action' on form itself.

If you want to submit values to Drupal and then redirect user to external site, you cannot do it directly. HTTP protocol does not allow you to send anything from your server to another "on behalf" of your user. The only way to do it is:


Get data from user
Save data, process it, do whatever you need
Generate form with action pointing to external service (usually payment gateway), and data required by it in hidden fields
Use JavaScript to make user's browser submit it.


If you are trying to do it using drupal_http_request, it's your server that starts payment procedure, not client's browser - certainly not what you want. And payment server will not allow switching procedure between different computers - it would be a security risk to allow that. If you could hand your session on payment server to your user, what would prevent attacker from doing the same (but with his bank account, not yours)? I know that's simplified explanation - for more details you may try to ask on Information Security.