When a user is created, deleted and update the system will give feed back. e.g. User Deleted/Updated/Create success or unsuccessfully, but I'm sure there is a better way to do it than what I have done because I repeat the same code in all functions within my class.
Code to create user
$userOne = new userActions($database, 'Greg', '324b2643243');//
echo $userOne->create();
Code to delete user
$userOne = new userActions($database, 'Abel'); //
echo $userOne->delete();
Code for user creation
public function create()
{//Works
$outPut = "";
if(!$this->user_exists)
{
list($password_hash, $salt) = $this->hash($this->password);
echo 'Hash: ' . $password_hash . '<br>' . 'Salt: ' . $salt . '<br />';
$result = $this->connection->query("INSERT INTO users VALUES( NULL, '{$this->username}' , '{$password_hash}' , '{$salt}' ) ");
if($result)
{
$outPut = "User has been created";
}
else
{
$outPut = "User could not be created";
}
}
else
{
$outPut = 'Username already exists';
}
return $outPut;
}
Is there a better way to display feedback to the user istead of having $outPut every time in all of my create, delete and update functions?