pl

class Customer{
public $firstName;
public $lastName;
public $pasword;
public $email;
public $gender;
public $address;
public $city;
public $state;
public $country;

}

class CustomerBLL
{
public saveCustomer()
{
var customer = new Customer();

if(empty($_POST[‘firstName’]))
throw new exception(“First Name is required”);
else
$customer->firstName = filter_var($str, FILTER_SANITIZE_STRING);

if(empty($_POST[‘lastName’]))
throw new exception(“Last Name is required”);
else
$customer->lastName = filter_var($_POST[‘lastName’], FILTER_SANITIZE_STRING);

if(empty($_POST[’email’]))
throw new exception(“Email is required”);
else if (!filter_var($_POST[’email’], FILTER_VALIDATE_EMAIL) === false) {

throw new exception(“Please enter a valid email address”);
else
$customer->email = filter_var($_POST[’email’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘password’]))
throw new exception(“Password is required”);
else if($_POST[‘password’] == $_POST[‘repassword’]
throw new exception(“Both Password must match”);
else
$customer->password = filter_var($_POST[‘password’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘gender’]))
throw new exception(“Gender is required”);
else
$customer->gender = filter_var($_POST[‘gender’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘address’]))
throw new exception(“Address is required”);
else
$customer->address = filter_var($_POST[‘address’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘city’]))
throw new exception(“City is required”);
else
$customer->city = filter_var($_POST[‘city’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘state’]))
throw new exception(“State is required”);
else
$customer->city = filter_var($_POST[‘state’], FILTER_SANITIZE_STRING);

if(empty($_POST[‘country’]))
throw new exception(“country is required”);
else
$customer->city = filter_var($_POST[‘country’], FILTER_SANITIZE_STRING);

var $customerDal = new CustomerDAL;
$customerDal->saveCusomter($customer);
return true;

}

public getCustomer($id){
if(filter_var(intval($id), FILTER_SANITIZE_INT)==false)
throw new exception(“Customer ID is invalid”);
else
{
$customerDal = new CustomerDal();
$customer = $customerDal->getCustomer(intval($id));
return $customer;
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s