</script>
</head>
<body>
<?php 
global $msg;
$msg = '';
if (isset($_POST["btnRegister"])) {
    $userName = $_POST['customerName'];
    $password = $_POST['customerPassword'];
    $home = $_POST['home'];
    $work = $_POST['work'];
    $mobile = $_POST['mobile'];
    $email = $_POST['email'];
    $service = new CustomerService();
    $sqln = "select * from customer where customer_name='{$userName}'";
    $num = $service->GetCount($sqln);
    if ($num > 0) {
        echo 'aa';
        $flag = false;
        $msg = "This user name has been exsited.";
    } else {
        $sql = " insert into customer ";
        $dataArray = array("customer_name" => "'" . $userName . "'", "customer_password" => "'" . $password . "'", "customer_home_phone" => "'" . $home . "'", "customer_work_phone" => "'" . $work . "'", "customer_mobile_phone" => "'" . $mobile . "'", "customer_email" => "'" . $email . "'", "customer_status" => "'available'");
        $sql .= $service->GetInsertSQL($dataArray);
        $id = $service->saveCustomer($sql, $email, $userName, $password);
        if ($id != 0) {
            //ok
            Redirect("Login.php?register=ok");
        } else {
        }
    }