Where and how to define variables for URLs etc

I believe you can just use site_url() + the path – so for instance:

<input type="hidden" name="cancelurl" value="<?php echo site_url('/cancel/'); ?>">