You go to the dragon's den (you need surf for this) then you go up the gym and there will be a house up ahead and you have to fight the old guy in the back. After that the gym leader will come in and give you your badge.
If you mean the Wifi Plaza, then it opens after you get your first or second badge I think.
By mystery man you mean the one in DPt? (Diamond, Pearl, and Platinum) the one that gives you items for your secret base. if that's the one he isn't in HeartGold or SoulSilver....... sorry :( hope i helped :)
First, go in the Gym and beat Claire. She will then refuse to give you the badge until you go to the dragons den. Exit the Gym, and surf behind it. There will be a cave there. Go in, go around, and take the test to be a dragon master. You need Whirlpool to get through. After this, she will give you the badge. Leave the cave and head to the Elite 4. Good luck.
* Pewter Gym - Rock Badge * Cerulean Gym - Cascade Badge * Vermillion Gym - Thunder Badge * Celadon Gym - Rainbow Badge * Fuchsia Gym - Soul Badge * Saffron Gym - Marsh Badge * Cinnabar Gym - Volcano Badge * Viridian Gym - Earth Badge
beat Clair and she will send you to a dragon den shrine. Then you must surf to the shrine and answer the old mans questions. Try to be as caring in your answers as possible. Then if you pass, Clair will walk in and blather on about how she never passed the test. Then the old man will practically yell at her and she will give you the rising badge. I hope this helps
KANTO
You can't get a HM for that.
by beating the gym leader
beat falker with a senret lv100
Go to the forth gym!
You can find it at the town team rocket is defending
cinbar islnd
you have to get the cianwood gym badge and the olivine gym badge
by beating the icicle gym leader. In mahogany town.
In Mahogany town right from Etrack city
blackthorn city
it is bugsy the bug type leader