title: Registration not working in magento
body: <p>magento 1.9X</p>
  
  <p>I am using below ref to create ajax login/reg popup.
  Login works fine. but not able to register.</p>
  
  <p><a href="http://fastdivision.com/2012/03/29/diy-magento-create-ajax-login-registration-forms-for-your-magento-theme/" rel="nofollow">http://fastdivision.com/2012/03/29/diy-magento-create-ajax-login-registration-forms-for-your-magento-theme/</a><br>
  It gives same error popup "Please make sure your passwords match". even if i use existing email.same popup error appears.</p>
  
  <p>config.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
  &lt;modules&gt;
      &lt;FastDivision_QuickLogin&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/FastDivision_QuickLogin&gt;
  &lt;/modules&gt;
  &lt;frontend&gt;
      &lt;routers&gt;
          &lt;customer&gt;
              &lt;args&gt;
                  &lt;modules&gt;
                      &lt;FastDivision_QuickLogin before="Mage_Customer"&gt;FastDivision_QuickLogin_Customer&lt;/FastDivision_QuickLogin&gt;
                      &lt;!--&lt;FastDivision_QuickLogin before="Mage_Customer_Account"&gt;FastDivision_QuickLogin_Customer&lt;/FastDivision_QuickLogin&gt;
                      &lt;FastDivision_QuickLogin before="Mage_Customer_AccountController"&gt;FastDivision_QuickLogin_Customer&lt;/FastDivision_QuickLogin&gt;--&gt;
                  &lt;/modules&gt;
              &lt;/args&gt;
          &lt;/customer&gt;
      &lt;/routers&gt;
  &lt;/frontend&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>AccountController.php</p>
  
  <pre><code>&lt;?php
  // Require the core controller file that you're planning to override
  require_once('Mage/Customer/controllers/AccountController.php');
  
  // The class name follows this format:
  // YOURPACKAGE_YOUREXTENSION_COREMODULEFOLDER_CONTROLLERFILENAME
  // We extend the original Mage_Customer_AccountController class to inherit unused actions and override specific actions
  class FastDivision_QuickLogin_Customer_AccountController extends Mage_Customer_AccountController
  {
  // Code referenced from AccountController.php
  public function loginPostAction()
  {
      if(!$this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
          if ($this-&gt;_getSession()-&gt;isLoggedIn()) {
              $this-&gt;_redirect('*/*/');
              return;
          }
      }
  
      $session = $this-&gt;_getSession();
  
      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
          // Report exceptions via JSON
          $ajaxExceptions = array();
      }
  
      if ($this-&gt;getRequest()-&gt;isPost()) {
          $login = $this-&gt;getRequest()-&gt;getPost('login');
          if (!empty($login['username']) &amp;&amp; !empty($login['password'])) {
              try {
                  $session-&gt;login($login['username'], $login['password']);
                  if ($session-&gt;getCustomer()-&gt;getIsJustConfirmed()) {
                      $this-&gt;_welcomeCustomer($session-&gt;getCustomer(), true);
                  }
              } catch (Mage_Core_Exception $e) {
                  if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                      $messages = array_unique(explode("\n", $e-&gt;getMessage()));
                      foreach ($messages as $message) {
                          $ajaxExceptions['exceptions'][] = $message;
                      }
                  } else {
                      switch ($e-&gt;getCode()) {
                          case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                              $value = Mage::helper('customer')-&gt;getEmailConfirmationUrl($login['username']);
                              $message = Mage::helper('customer')-&gt;__('This account is not confirmed. &lt;a href="%s"&gt;Click here&lt;/a&gt; to resend confirmation email.', $value);
                              break;
                          case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                              $message = $e-&gt;getMessage();
                              break;
                          default:
                              $message = $e-&gt;getMessage();
                      }
                      $session-&gt;addError($message);
                  }
  
                  $session-&gt;setUsername($login['username']);
              } catch (Exception $e) {
                  // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
              }
          } else {
              if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                  $ajaxExceptions['exceptions'][] = 'Login and password are required.';
              } else {
                  $session-&gt;addError($this-&gt;__('Login and password are required.'));
              }
          }
      }
  
      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
          // If errors
          if(count($ajaxExceptions)) {
              echo json_encode($ajaxExceptions);
          } else {
              // No Errors
              echo json_encode(array('success' =&gt; 'success'));
          }
      } else {
          // Redirect for non-ajax
          $this-&gt;_loginPostRedirect();
      }
  }
  
  // Create Account
  public function createPostAction()
  {
      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
          // Report exceptions via JSON
          $ajaxExceptions = array();
      }
  
      $session = $this-&gt;_getSession();
      if ($session-&gt;isLoggedIn()) {
          $this-&gt;_redirect('*/*/');
          return;
      }
      $session-&gt;setEscapeMessages(true); // prevent XSS injection in user input
      if ($this-&gt;getRequest()-&gt;isPost()) {
          $errors = array();
  
          if (!$customer = Mage::registry('current_customer')) {
              $customer = Mage::getModel('customer/customer')-&gt;setId(null);
          }
  
          /* @var $customerForm Mage_Customer_Model_Form */
          $customerForm = Mage::getModel('customer/form');
          $customerForm-&gt;setFormCode('customer_account_create')
              -&gt;setEntity($customer);
  
          $customerData = $customerForm-&gt;extractData($this-&gt;getRequest());
  
          if ($this-&gt;getRequest()-&gt;getParam('is_subscribed', false)) {
              $customer-&gt;setIsSubscribed(1);
          }
  
          /**
           * Initialize customer group id
           */
          $customer-&gt;getGroupId();
  
          if ($this-&gt;getRequest()-&gt;getPost('create_address')) {
              /* @var $address Mage_Customer_Model_Address */
              $address = Mage::getModel('customer/address');
              /* @var $addressForm Mage_Customer_Model_Form */
              $addressForm = Mage::getModel('customer/form');
              $addressForm-&gt;setFormCode('customer_register_address')
                  -&gt;setEntity($address);
  
              $addressData    = $addressForm-&gt;extractData($this-&gt;getRequest(), 'address', false);
              $addressErrors  = $addressForm-&gt;validateData($addressData);
              if ($addressErrors === true) {
                  $address-&gt;setId(null)
                      -&gt;setIsDefaultBilling($this-&gt;getRequest()-&gt;getParam('default_billing', false))
                      -&gt;setIsDefaultShipping($this-&gt;getRequest()-&gt;getParam('default_shipping', false));
                  $addressForm-&gt;compactData($addressData);
                  $customer-&gt;addAddress($address);
  
                  $addressErrors = $address-&gt;validate();
                  if (is_array($addressErrors)) {
                      $errors = array_merge($errors, $addressErrors);
                  }
              } else {
                  $errors = array_merge($errors, $addressErrors);
              }
          }
  
          try {
              $customerErrors = $customerForm-&gt;validateData($customerData);
              if ($customerErrors !== true) {
                  $errors = array_merge($customerErrors, $errors);
              } else {
                  $customerForm-&gt;compactData($customerData);
                  $customer-&gt;setPassword($this-&gt;getRequest()-&gt;getPost('password'));
                  $customer-&gt;setConfirmation($this-&gt;getRequest()-&gt;getPost('confirmation'));
                  $customerErrors = $customer-&gt;validate();
                  if (is_array($customerErrors)) {
                      $errors = array_merge($customerErrors, $errors);
                  }
              }
  
              $validationResult = count($errors) == 0;
  
              if (true === $validationResult) {
                  $customer-&gt;save();
  
                  Mage::dispatchEvent('customer_register_success',
                      array('account_controller' =&gt; $this, 'customer' =&gt; $customer)
                  );
  
                  if ($customer-&gt;isConfirmationRequired()) {
                      $customer-&gt;sendNewAccountEmail(
                          'confirmation',
                          $session-&gt;getBeforeAuthUrl(),
                          Mage::app()-&gt;getStore()-&gt;getId()
                      );
                      $session-&gt;addSuccess($this-&gt;__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please &lt;a href="%s"&gt;click here&lt;/a&gt;.', Mage::helper('customer')-&gt;getEmailConfirmationUrl($customer-&gt;getEmail())));
  
                      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                          echo json_encode(array('success' =&gt; $this-&gt;__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please &lt;a href="%s"&gt;click here&lt;/a&gt;.', Mage::helper('customer')-&gt;getEmailConfirmationUrl($customer-&gt;getEmail()))));
                      } else {
                          $this-&gt;_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=&gt;true)));
                      }
  
                      return;
                  } else {
                      $session-&gt;setCustomerAsLoggedIn($customer);
                      $url = $this-&gt;_welcomeCustomer($customer);
  
                      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                          echo json_encode(array('success' =&gt; 'success'));
                      } else {
                          $this-&gt;_redirectSuccess($url);
                      }
  
                      return;
                  }
              } else {
                  $session-&gt;setCustomerFormData($this-&gt;getRequest()-&gt;getPost());
  
                  if(!$this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                      if (is_array($errors)) {
                          foreach ($errors as $errorMessage) {
                              $session-&gt;addError($errorMessage);
                          }
                      } else {
                          $session-&gt;addError($this-&gt;__('Invalid customer data'));
                      }
                  } else {
                      if (is_array($errors)) {
                          foreach ($errors as $errorMessage) {
                              $ajaxExceptions['exceptions'][] = $errorMessage;
                          }
                      } else {
                          $ajaxExceptions['exceptions'][] = 'Invalid customer data';
                      }
                  }
              }
          } catch (Mage_Core_Exception $e) {
              $session-&gt;setCustomerFormData($this-&gt;getRequest()-&gt;getPost());
              if ($e-&gt;getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                  $url = Mage::getUrl('customer/account/forgotpassword');
                  $message = $this-&gt;__('There is already an account with this email address. If you are sure that it is your email address, &lt;a href="%s"&gt;click here&lt;/a&gt; to get your password and access your account.', $url);
                  $session-&gt;setEscapeMessages(false);
              } else {
                  $message = $e-&gt;getMessage();
              }
  
              if(!$this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                  $session-&gt;addError($message);
              } else {
                  $messages = array_unique(explode("\n", $e-&gt;getMessage()));
                  foreach ($messages as $message) {
                      $ajaxExceptions['exceptions'][] = $message;
                  }
              }
          } catch (Exception $e) {
              if(!$this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
                  $session-&gt;setCustomerFormData($this-&gt;getRequest()-&gt;getPost())
                  -&gt;addException($e, $this-&gt;__('Cannot save the customer.'));
              } else {
                  $ajaxExceptions['exceptions'][] = 'Cannot save the customer.';
              }
          }
      }
  
      if($this-&gt;getRequest()-&gt;isXmlHttpRequest()) {
          echo json_encode($ajaxExceptions);
      } else {
          $this-&gt;_redirectError(Mage::getUrl('*/*/create', array('_secure' =&gt; true)));
      }
  }
  }
  </code></pre>
  
  <p>quick_login.phtml</p>
  
  <pre><code>    &lt;div id="login-modal" class="modal-window"&gt;
    &lt;div id="login-modal-content"&gt;
      &lt;div id="signup-box"&gt;
    &lt;h1&gt;Register&lt;/h1&gt;
    &lt;p&gt;&lt;a href="#" id="already-registered-link"&gt;Already registered? Click here to sign in.&lt;/a&gt;&lt;/p&gt;
  
    &lt;form action="&lt;?php echo Mage::getBaseUrl() ?&gt;customer/account/createpost/" method="post" id="signup-form" class="site-form" onsubmit="return false"&gt;
      &lt;ul class="form-list"&gt;
        &lt;li class="fields"&gt;
            &lt;div class="field first-field"&gt;
                &lt;label for="firstname" class="required"&gt;&lt;?php echo $this-&gt;__('First Name') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
                &lt;div class="input-box"&gt;
                    &lt;input type="text" name="firstname" id="firstname" class="input-text validate-email required-entry" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="field"&gt;
                &lt;label for="last_name" class="required"&gt;&lt;?php echo $this-&gt;__('Last Name') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
                &lt;div class="input-box"&gt;
                    &lt;input type="text" name="lastname" id="lastname" class="input-text validate-email required-entry" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="field"&gt;
                &lt;label for="email_address" class="required"&gt;&lt;?php echo $this-&gt;__('Email') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
                &lt;div class="input-box"&gt;
                    &lt;input type="text" name="email" id="email_address" class="input-text validate-email required-entry" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="field"&gt;
                &lt;label for="password" class="required"&gt;&lt;?php echo $this-&gt;__('Password') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
                &lt;div class="input-box"&gt;
                    &lt;input type="password" name="password" id="password" title="&lt;?php echo $this-&gt;__('Password') ?&gt;" class="input-text required-entry validate-password" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="field"&gt;
                &lt;label for="confirmation" class="required"&gt;&lt;?php echo $this-&gt;__('Confirm Password') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
                &lt;div class="input-box"&gt;
                    &lt;input type="password" name="confirmation" title="&lt;?php echo $this-&gt;__('Confirm Password') ?&gt;" id="confirmation" class="input-text required-entry validate-cpassword" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;button type="submit" title="Submit" class="action-button"&gt;&lt;span&gt;Create Account&lt;/span&gt;&lt;/button&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  &lt;div id="login-box"&gt;
    &lt;h1&gt;Login&lt;/h1&gt;
    &lt;p&gt;&lt;?php echo $this-&gt;__('If you have an account with us, please log in.') ?&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="#" id="need-account-link"&gt;Need an account? Click here to register.&lt;/a&gt;&lt;/p&gt;
  
    &lt;form action="&lt;?php echo Mage::getBaseUrl() ?&gt;customer/account/loginPost/" method="post" id="login-form" class="site-form" onsubmit="return false"&gt;
      &lt;ul class="form-list"&gt;
           &lt;li class="field"&gt;
               &lt;label for="email" class="required"&gt;&lt;?php echo $this-&gt;__('Email') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
               &lt;div class="input-box"&gt;
                   &lt;input type="text" name="login[username]" value="&lt;?php echo $this-&gt;htmlEscape($this-&gt;getUsername()) ?&gt;" id="email" class="input-text" title="&lt;?php echo $this-&gt;__('Email Address') ?&gt;" /&gt;
               &lt;/div&gt;
           &lt;/li&gt;
           &lt;li class="field"&gt;
               &lt;label for="pass" class="required"&gt;&lt;?php echo $this-&gt;__('Password') ?&gt;&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
               &lt;div class="input-box"&gt;
                   &lt;input type="password" name="login[password]" class="input-text" id="pass" title="&lt;?php echo $this-&gt;__('Password') ?&gt;" /&gt;
               &lt;/div&gt;
           &lt;/li&gt;
       &lt;/ul&gt;
  
        &lt;button type="submit" class="action-button action-button-no-arrow" title="&lt;?php echo $this-&gt;__('Login') ?&gt;" name="send" id="send2"&gt;&lt;span&gt;&lt;?php echo $this-&gt;__('Login') ?&gt;&lt;/span&gt;&lt;/button&gt;&amp;nbsp;&amp;nbsp;
        &lt;a href="&lt;?php echo $this-&gt;getForgotPasswordUrl() ?&gt;" class="small"&gt;&lt;?php echo $this-&gt;__('Forgot Your Password?') ?&gt;&lt;/a&gt;
         &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;a id="close_x" class="close" href="#"&gt;&lt;i class="fa fa-close"&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;script type="text/javascript"&gt;
    //&lt;![CDATA[
    var dataForm = new VarienForm('login-form', true);
    //]]&gt;
    &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>