title: cant read paypal status
body: <p>I am trying to integrate paypal for my website. But I have a problem to get the response status from paypal. This is my paypal request.</p>
  
  <pre><code> &lt;?php
      $paypal_url = 'https://www.sandbox.paypal.com/us/cgi-bin/webscr';
      $paypal_id = 'MY DEVELOPER ACC';//This is your seller id
  
      $cancel_url = 'http://xyz/index.php';
      $return_url = 'http://xyz/process_payment.php';
  
      $products = array();
      $products[] = array('id'=&gt;$sub,'price'=&gt;$price); 
        foreach($products as $product)
        {
           ?&gt;
  
       &lt;form id='payment_form' action='&lt;?php echo $paypal_url ?&gt;' method='post' name='payform' /&gt;
        &lt;input type='hidden' name='business' value='&lt;?php echo $paypal_id ?&gt;' /&gt;
        &lt;input type='hidden' name='cmd' value='_xclick' /&gt;
        &lt;input type='hidden' name='amount' value='&lt;?php echo $product['price'] ?&gt;' /&gt;
        &lt;input type='hidden' name='no_shipping' value='0' /&gt;
        &lt;input type='hidden' name='item_name' value='&lt;?php echo $product['name'] ?&gt;' /&gt;
        &lt;input type='hidden' name='item_number' value='&lt;?php echo $product['id'] ?&gt;' /&gt;
        &lt;input type='hidden' name='invoice' value='WS-&lt;?php echo $product['id'] ?&gt;' /&gt;
        &lt;input type='hidden' name='currency_code' value='USD' /&gt;
        &lt;input type='hidden' name='cancel_return' value='&lt;?php echo $cancel_url ?&gt;' /&gt;
        &lt;input type='hidden' name='return' value='&lt;?php echo $return_url ?&gt;' /&gt;
        &lt;input type='image'src='https://www.sandbox.paypal.com/en_US/i/btn/btn_buynow_SM.gif'name='submit' style='display:{$display_button}' /&gt;
       &lt;/form&gt;   
      &lt;/div&gt;                     
     &lt;/div&gt;
    &lt;?php
    }
    ?&gt;
  </code></pre>
  
  <p>When response comes from paypal I can mail all response information but can't see it when I am trying to <code>echo</code> all values and can't update my database status.</p>
  
  <p>This is my process code</p>
  
  <pre><code>    &lt;?php
      session_start();
  
      include('connection.php');
      $paypal_response = $_REQUEST;
  
      //Check if it is the response from PayPal
      if ( isset( $paypal_response ) ) {
  
        $tx = $paypal_response['tx'];//Transaction code
        $st = strtolower($paypal_response['payment_status']);//Payment status
        $amount = $paypal_response['mc_gross'];//Amount
        $cc = $paypal_response['mc_currency'];//Currency code
        $item_number = $paypal_response['item_number'];//Item number
        $invoice_id = $paypal_response['invoice'];
  
       $user_email = 'MY GMAIL ID';
  
       $site_name = 'MY WEBSITE NAME';
       $eol = "\r\n";
       $headers  = 'MIME-Version: 1.0' . $eol;
       $headers .= 'Content-type: text/html; charset=iso-8859-1' . $eol;
       $headers .= 'From:' . $site_name . ' &lt;EMAIL ID&gt;'. $eol;
       $headers .= 'Reply-To:' . $site_name . ' &lt;EMAIL ID&gt;' . $eol;
       $headers .= 'Return-Path:' . $site_name . ' &lt;EMAIL ID&gt;' . $eol;
  
       $eol = "\r\n&lt;br /&gt;";
       $thanks_text = $eol.$eol.'Thanks!'. $eol;
  
       if($st == 'completed')
          {//Payment has been completed successfully
          //if payment success
          if(isset($_SESSION['email']) &amp;&amp; ($_SESSION['price']) &amp;&amp; ($_SESSION['sub']) &amp;&amp; ($_SESSION['result']) )
              {
                      include('connection.php');
                      $email=$_SESSION['email'];
                      $_SESSION['email']=$email;
                      $price=$_SESSION['price'];
                      $_SESSION['price']=$price;
                      $sub=$_SESSION['sub'];
                      $result=$_SESSION['result'];
                      $time=date("y/m/d");
                      $qry="update user set coursestatus='completed', score='$result',timestamp='$time'  where courseno='$sub' and email='$email'";
                      $run_qry=mysql_query($qry);
  
                      if($run_qry)
                      {
                  ?&gt;
                   &lt;script language="javascript" type="text/javascript"&gt;
              // Print a message
              alert('Thank you for your purchase! your Payment was successfull. Now You can print and download your certificate');
                  // Redirect to some page of the site.
              window.location = 'course_completed.php';
                  &lt;/script&gt;
                  &lt;?php
                      }
  
                      else
                      {
                      echo mysql_error();
                      }
          }
  
  
      }
  
  
  
  
  
    //Send succes email to user   $email_tpl = 'Hello Buyer,' . $eol;  
   $email_tpl .= "We have received your payment of $amount $cc." . $eol; 
   $email_tpl .= "Your status is $st ." . $eol;   $email_tpl .= "Thanks
   for the purchase." . $eol;   $email_tpl .= $eol . $thanks_text;
  
     mail ($user_email, 'Payment Received', $email_tpl, $headers);
          }   ?&gt;
  </code></pre>