title: magento onload form submit
body: <p>i want to have a redirect to magento login from sugarcrm.
  My idea is to have on bodyload form submit and redirect the form to magento.</p>
  
  <p>I have a file in sugarcrm when i click the contacts it has to login to the magento admin panel and redirect to dashboard
  The filename is sugarfile.php in sugarfolder</p>
  
  <pre><code>if($_REQUEST['module']== 'Contacts')
  {
  header('Location:http://mysite/magento/redirect.php');
  exit;
  }
  </code></pre>
  
  <p>In magento folder i have a file redirect.php
  the code is below but its taking a long time and it is not redirecting at all</p>
  
  <pre><code>&lt;?php
  // Include Magento application
  require_once ( "/var/www/html/santosh/magento/app/Mage.php" );
  umask(0);
  Mage::app("default");
  Mage::getSingleton("core/session", array("name" =&gt; "adminhtml"));
  $session = Mage::getSingleton("admin/session");
  if(!isset($_REQUEST['action'])) {
  $_REQUEST['action'] = '';
  }
   $_REQUEST['action'] = "login";
  switch($_REQUEST['action']){
  case "login":
  try{
  $login = $session-&gt;login('admin','admin');
  }catch(Exception $e){
  $message = $e-&gt;getMessage();
  }
  
  header("location: http://mysite/magento/index.php/admin/dashboard/");
  
  break;
  case "logout":
  // Execute the logout request
  $session-&gt;logout();
  header("location: index.php");
  
  break;
  default:
  // If the customer is not logged in, show login form
  // else, show logout link
  if(!$session-&gt;isLoggedIn()){
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;External Page for Magento&lt;/title&gt;
  &lt;script language="javascript"&gt; 
  
  function onBodyLoad() 
  { 
     document.form.submit() 
  } 
  &lt;/script&gt; 
  &lt;/head&gt;
  &lt;body onload="onBodyLoad();"&gt;
  &lt;h3&gt;Login here&lt;/h3&gt;
  &lt;form method="POST" name="form" action="index.php/admin/"&gt;
  Username &lt;input type="text" name="login[username]" size="10" value="admin"/&gt;
  Password &lt;input type="password" name="login[password]" size="10" value="admin" /&gt;
  &lt;input type="submit" name="submit" value="login" /&gt;
  &lt;input type="hidden" name="action" value="login" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
  }
  }
  ?&gt;
  </code></pre>
  
  <p>where am I going wrong?</p>