magento onload表单提交

时间:2011-02-14 13:47:59

标签: php javascript magento

我希望从sugarcrm重定向到magento登录。 我的想法是在bodyload表单上提交并将表单重定向到magento。

当我点击联系人登录magento管理面板并重定向到仪表板时,我在sugarcrm中有一个文件 文件名是sugarfolder中的sugarfile.php

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

在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
}
}
?>

我哪里错了?

1 个答案:

答案 0 :(得分:2)

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