Help with hashtags, how to replace them

hi there please anyone could help me out?
I am currently using PPPOE for my clients and everytime a pppoe client disconnect i want it to hit a link on my website to give it get request so that it can save the data to mysql.
Currently users with # doesnt seem to work

For now users with just text and numbers are fine
example ------
PPPOE on down
:local nama “$user”;
/tool fetch url=“https://example.com/number=$user&bid=BID202202004”;


So the $user is just the username of the pppoe user.

Now i have problems with pppoe usernames such as : SR#kennedy

I need it hit the website like this example
On down
Lets say the user is SR#kennedy
:local nama “$user”;
/tool fetch url=“https://example.com/number=SR%23kennedy &bid=BID202202004”; ← somehow to make it work this way sir

i am new to scripting in mikrotik , could you kindly help me make a script that i can just copy paste into mikrotik. I will be placing this script on ppp>profile>scripts>on down and on up

Thanks a million