xml - Custom Login page in magento? -
i new in magento, have custom login page form , after login redirect account information, how can this? need magento experienced persons,
here giving skeleton code login please check actual code , files
login controller action like
public function loginaction() { $session = mage::getsingleton('customer/session'); if ($session->isloggedin()) { // login redirect account page return; } $result = array('success' => false); if ($this->getrequest()->ispost()) { $login_data = $this->getrequest()->getpost('login'); if (empty($login_data['username']) || empty($login_data['password'])) { $result['error'] = mage::helper('onepagecheckout')->__('login , password required.'); } else { try { $session->login($login_data['username'], $login_data['password']); $result['success'] = true; $result['redirect'] = mage::geturl('*/*/index'); } catch (mage_core_exception $e) { switch ($e->getcode()) { case mage_customer_model_customer::exception_email_not_confirmed: $message = mage::helper('onepagecheckout')->__('email not confirmed. <a href="%s">resend confirmation email.</a>', mage::helper('customer')->getemailconfirmationurl($login_data['username'])); break; default: $message = $e->getmessage(); } $result['error'] = $message; $session->setusername($login_data['username']); } } } $this->getresponse()->setbody(mage::helper('core')->jsonencode($result)); } and form would like
<?php $login_url = $this->geturl('*/*/login', array('_secure'=>(!empty($_server['https']) && $_server['https']==='on'))); $http_mode = (!empty($_server['https']) && $_server['https']==='on'); if($http_mode) $login_url = str_replace('http:', 'https:', $login_url); ?> <form method="post" id="login-form" action="<?php echo $login_url ?>"> <div class='full'> <label> <?php echo $this->__('email address') ?> </label> <sup>*</sup> <div class="data_area"> <input type="text" name="login[username]" value="<?php echo $this->htmlescape($this->getusername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('email address') ?>" /> </div> </div> <div class='full'> <label> <?php echo $this->__('password') ?> </label> <sup>*</sup> <div class="input-box"> <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('password') ?>" /> </div> </div> <button type="submit" class="button" title="<?php echo $this->__('login') ?>" name="send" id="send2"><span><span><?php echo $this->__('login') ?></span></span></button> <script type="text/javascript"> //<![cdata[ var loginform = new varienform('login-form', true); //]]> </script> above example ajax can convert sample redirect myaccount page in controller.
Comments
Post a Comment