title: How to get Order No. at event sales_order_place_after using event-observer model?
body: <p>How to get Order No. at event sales_order_place_after using event-observer model?</p>
  
  <p>I want to get Order No. as soon as order is placed by customer.</p>
  
  <p>I want to pass that order no. to another external php file &amp; include that php file in the Observer.php? How Can I do that?</p>
  
  <p>I am trying to include external php file in Magento but I am unable to do that. </p>
  
  <p>Observer.php: </p>
  
  <pre><code>&lt;?php
  
   include("connection/Final/Function1.php");     
  class Sample_Event_Model_Observer {
  
      public function Mytestmethod($observer) {
  
          $event = $observer-&gt;getEvent();  //Fetches the current event
          $eventmsg = "Current Event Triggered : &lt;I&gt;" . $event-&gt;getName() . "&lt;/I&gt;";
          echo Mage::getSingleton('checkout/session')-&gt;addSuccess($eventmsg);
  
      $Id = $observer-&gt;getEvent()-&gt;getOrder()-&gt;getId();   
      $incrementid = $observer-&gt;getEvent()-&gt;getOrder()-&gt;getIncrementId();
  
      $ordermsg1 = "Current order Id : &lt;I&gt;" . $Id . "&lt;/I&gt;";
          echo Mage::getSingleton('checkout/session')-&gt;addSuccess($ordermsg1);
      $ordermsg2 = "Current increment Id : &lt;I&gt;" . $incrementid . "&lt;/I&gt;";
          echo Mage::getSingleton('checkout/session')-&gt;addSuccess($ordermsg2);
  
      $p = new testDatabase(); 
          $p -&gt; setId($incrementid);
          $p -&gt; dbConnect();
        }
  }
  ?&gt;  
  </code></pre>
  
  <p>Function1.php:</p>
  
  <pre><code>&lt;?php 
  class testDatabase 
  { 
      public function setId($getId)
      {
          $incrementid=$getId;
          echo $incrementid;
      }
  
      public function dbConnect()
       {  
              $db_name = "magento";
                  $con = mysql_connect("localhost", "magento", "password");
  
          If (!$con)
          {
              die('Could not connect: ' . mysql_error());
          }
              $seldb = mysql_select_db($db_name, $con);
          If ($seldb) 
          {
              echo "Database Found ";
              $query = "INSERT INTO sample(id) VALUES($incrementid)" ;
              $result = mysql_query($query);
              print "id is added to the database"; 
              mysql_close($seldb);
          }
          else 
          {
              echo "Database NOT Found ";
          } 
       }
  }
  </code></pre>
  
  <p>How can I access variable <code>$incrementid</code> in <code>Function1.php</code>?  My problem is I am unable to access <code>$incrementid</code> as it is unable to insert in my sample table. </p>
  
  <p>I have caught s<code>ales_order_place_after</code> event. So that once customer press PLACE ORDER, I can include Function1.php &amp; it will take increment/order id &amp; I can able to access Functions in it that will do needful job.</p>