You need to delete all the forum_id query variables, then add the one you need. rp_form_put just appends a new query variable to the form. It puts it on the end, so the first value will be the original, if any.
For instance try the following link, which is setup like this:
ad_page_contract {
@author tom jackson
}
set forum_id [lindex [ad_conn urlv] end]
rp_form_put forum_id $forum_id
rp_internal_redirect forum-view
rp_form_put test
The query variable is just appended, leading to the error message. You can't use replace, because this is equivalant of delkey and put. If there are more than one forum_id variables, the wrong one might be used. Also, replace is case sensitive, whereas the loop I'm using is case insensitive.