开发者

magento onload form submit

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.

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

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

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

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

where am I going wrong?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜