0

I want to show message box with javascript with some codition from database, this is the example: controller

$email_cek     = $this->model_select->select_member('where email = "$email"');
    if($email_cek == 0){
    $facebook           = $this->input->post('facebook');
    $facebook_cek       = $this->model_select->select_member('where facebook = "$facebook"');
    if($facebook_cek == 0){
        //other script
    }else{
        echo "
        alert('You can't use that facebook account because the account has been used by another member! save aborted!');
        window.location.href='membership';
        ";
    }
    }else{
    echo "
    alert('Your e-mail is exist by another member! save aborted!');
    window.location.href='membership';
    ";
}
model
public function select_member($id=""){
    $data_member = $this->db->query("select * from member ".$id);
    return $data_member->result_array();
    }
I have two forms twitter and facebook, and the existing data in database. if input type same or exist in database, I want to display a message according to the data that already exists. but why the message always email messagebox show??

1
  • return form model is an array. so if you want to compare or check the number of data you must use php function to count total data in array Commented Aug 30, 2015 at 5:16

1 Answer 1

0

try model :

public function select_member($id=""){
    $data = $this->db->query("select * from member ".$id);
    return $data;
}

Controller :

$email_cek     = $this->model_select->select_member('where email = "$email"');
if($email_cek->num_rows() == 0){
    $facebook           = $this->input->post('facebook');
    $facebook_cek       = $this->model_select->select_member('where facebook = "$facebook"');
    if($facebook_cek->num_rows() == 0){
        //other script
    }else{
        echo "
        alert('You can't use that facebook account because the account has been used by another member! save aborted!');
        window.location.href='membership';
        ";
    }
}else{
    echo "
    alert('Your e-mail is exist by another member! save aborted!');
    window.location.href='membership';
    ";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.