Question: I am doing the check email before register. But I can't check with code. I need help from everybody

```
public function createPersonAction(){

$data = $this->getRequest()->getPost();

$session = Mage::getSingleton('core/session');

$person = Mage::getModel('course/course');

        $person->setData('course_name',$data['course_name']);
        $person->setData('course_email',$data['course_email']);
        $person->setData('course_courses',$data['course_courses']);
        $person->setData('course_age',$data['course_age']);
        $person->setData('course_gender',$data['course_gender']);
        //$person->setData('course_image',$data['course_image']);
        try{
            //$customer = Mage::getModel('course/course');
            $person->setWebsiteId(Mage::app()->getWebsite()->getId());
            $person->loadByEmail($course_email);
            if($person->getId())
            {
                "Email Exist";
            }
            $person->save();
            $session->addSuccess('Add a person sucessfully');
        } catch(Exception $e){
            $session->addError('Add Error');
        }
        $this->_redirect('');
    }

```

Answer: 
check below code

I just check the email id exists or not if exist then print exist message or not exist then save customer

I have to check static email id to exist you pass dynamic in code

for example **$email ="xyz@gmail.com";** 

```
<?php

public function createPersonAction()
{

    $data = $this->getRequest()->getPost();
    $session = Mage::getSingleton('core/session');
    $person = Mage::getModel('course/course');

    $person->setData('course_name',$data['course_name']);
    $person->setData('course_email',$data['course_email']);
    $person->setData('course_courses',$data['course_courses']);
    $person->setData('course_age',$data['course_age']);
    $person->setData('course_gender',$data['course_gender']);
    try{
        $email ="xyz@gmail.com";
        $customer = Mage::getModel('customer/customer');
        $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
        $customer->loadByEmail($email);
        if($customer->getId())
        {
          "Customer Exist";
           die();
        }else {
        $person->save();
        $session->addSuccess('Add a person sucessfully');
        }
    } catch(Exception $e){
        $session->addError('Add Error');
    }
    $this->_redirect('');
}

```

I hope this will help you.
```
Try this answer- 

public function createPersonAction(){

$data = $this->getRequest()->getPost();
$session = Mage::getSingleton('core/session');
$person = Mage::getModel('course/course');

try {
        $person->setData('course_name',$data['course_name']);
        $person->setData('course_email',$data['course_email']);
        $person->setData('course_courses',$data['course_courses']);
        $person->setData('course_age',$data['course_age']);
        $person->setData('course_gender',$data['course_gender']);
        $person->setWebsiteId(Mage::app()->getWebsite()->getId());
        $person->loadByEmail($course_email);
        if($person->getId())
        {
        $person->save();
        $session->addSuccess('Add a person sucessfully');
        }        
    } catch(Exception $e) {
        $session->addError('Add Error');
    }
    $this->_redirect('');
}

```