Changing a PayPal form button to code?

This is probably a very simple question for people here.

I have a PayPal button, that changes depending on different things on a web site.
The code I have from PayPal is echoed on my page as a form with the code included for the correct amount.

Now I would like this code to happen on another page.
When a user is clicking on a link I have called PAY, they should end up at a page called pay.php

In this page I want the PayPal action to happen. So, I just want to get rid of the form codes and the image and make that part as a header or whatever to send the user to PayPal with the correct code included. But I’m not sure how to do it.

I have to change this for security reasons and make it on a separate page.

This is what the code looks like:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="unique code">
<input type="image" src="http://website.com/pay.jpg" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Or is it possible to add the unique code to an URL?

Could the URL be like this to work?


https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&&hosted_button_id=unique code