Here is a simple code for user input information, the first if's condition is this->sanitize, to check the data is valid or not, another is this->haveDuplicateUser_nameAndEmail(), which is use to check the user name and email is existed in the db or not. the third one is this->addNewUser(), which add the user record to the db.
if(!$this->sanitize()){
$this->printError(); //the data is not sanitize
return;
}else{
if($this->haveDuplicateUser_nameAndEmail()){ //duplicateUserNameAndPassword, cannot add new user
$this->printError();
}else{
if($this->addNewUser()){
$this->printSuccess(); //add user success
}else{
$this->printError(); //add user fail
}
}
}