That would be easy to do:
$sLink = sprintf('http://example.com/%d/etc', isset($_POST['yourinputname']) ? (int)$_POST['yourinputname'] : 0);
You'll need to do plenty more though. If you don't want to link to be invalid, then you need to take this result and read that location to see if it returns a 200. If it does, then its good.
If its on your own site, don't apply the http://example.com
to it. This is implicit and it will make it easier to determine if a directory or file exists. If you need it to persist, look into using a session
to carry the data around.