Append data to session string

If you use sessions, you can return 2 error messages in one jQuery or php message.

As example you can return error from function... as:

$user = 'John';

function check_ifexists($user){
   ....
  if($data !== false){
     // this will create first session message
     $_SESSION['error_msg'] = "User $username already exists.";
     return true;
  }else
     return false;
}

and on your form page you can apply your second error message :

if (create_user($user)){
     ...
} else{
  // append second message to session
 if(isset($_SESSION['error_msg'])){  
     $_SESSION['error_msg'].=" - User is not created! ";
 } else {
     $_SESSION['error_msg']=" Oosops - User is not created! ";
 }
}

What will give output as:

User John already exists. - User is not created!