if ($type == 'log') { $info = array('passed' => false, 'content' => ''); $validation = $validate->check($_POST, array('email' => array('required' => true), 'password' => array('required' => true))); if ($validation->passed()) { if ($validation->login_correct()) { $info['passed'] = true; //$info ['content']=Alert::correct_signup(); } else { $info['content'] = Alert::return_error_div($validation->returnErrors()); } } else { $info['content'] = Alert::return_error_div($validation->returnErrors()); } echo $info['content']; // echo php_encode($info); } else { if ($type == 'sign') { $validation = $validate->check($_POST, array('first_name' => array('required' => true), 'last_name' => array('required' => true), 'email' => array('required' => true, 'unique' => 'email', 'format' => 'email'), 'password' => array('required' => true, 'min' => 6))); //connect to database if there are no errors if ($validation->passed()) { $instance = DB::getInstance(); $salt = Hash::salt(10); $hashed_password = Hash::make($_POST['password'], $salt); $instance->query('INSERT INTO user (email , password , salt , first_name , last_name ) VALUES (? , ? , ? , ? , ? )', array($_POST['email'], $hashed_password, $salt, $_POST['first_name'], $_POST['last_name'])); Alert::correct('You have successfully entered the data. Please check your e-mail to complete the sign-up.'); //send email functionality will come here } else { Alert::return_error_div($validation->returnErrors()); } } }