2011-02-14 50 views
0

我想要重定向到來自sugarcrm的magento登錄。 我的想法是在Bodyload表單上提交併將表單重定向到magento。magento onload form提交

我在SugarCRM的文件時,我點擊它來登錄到Magento管理面板中的聯繫人和重定向到儀表板 的文件名是sugarfolder

if($_REQUEST['module']== 'Contacts') 
{ 
header('Location:http://mysite/magento/redirect.php'); 
exit; 
} 

sugarfile.php在Magento文件夾中,我有一個文件redirect.php 代碼以下,但其花費很長的時間,它是不是在所有

<?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" => "adminhtml")); 
$session = Mage::getSingleton("admin/session"); 
if(!isset($_REQUEST['action'])) { 
$_REQUEST['action'] = ''; 
} 
$_REQUEST['action'] = "login"; 
switch($_REQUEST['action']){ 
case "login": 
try{ 
$login = $session->login('admin','admin'); 
}catch(Exception $e){ 
$message = $e->getMessage(); 
} 

header("location: http://mysite/magento/index.php/admin/dashboard/"); 

break; 
case "logout": 
// Execute the logout request 
$session->logout(); 
header("location: index.php"); 

break; 
default: 
// If the customer is not logged in, show login form 
// else, show logout link 
if(!$session->isLoggedIn()){ 
?> 
<html> 
<head> 
<title>External Page for Magento</title> 
<script language="javascript"> 

function onBodyLoad() 
{ 
    document.form.submit() 
} 
</script> 
</head> 
<body onload="onBodyLoad();"> 
<h3>Login here</h3> 
<form method="POST" name="form" action="index.php/admin/"> 
Username <input type="text" name="login[username]" size="10" value="admin"/> 
Password <input type="password" name="login[password]" size="10" value="admin" /> 
<input type="submit" name="submit" value="login" /> 
<input type="hidden" name="action" value="login" /> 
</form> 
</body> 
</html> 
<?php 
} 
} 
?> 

重定向我要去哪裏錯了?

回答

2
<body onLoad="document.form_name.submit()">