I should note that if any user puts the string "$1" and/or "$2" in his/her input box(es), then you will be mildly hosed: you could get unexpected results.

We might be better off using a different special character, in place of $. @ might be a good choice.