Yes, you would want to add a couple of php blocks around the code you want to have conditionally show:
<?php if (isset($_REQUEST["ref"])) { ?>
<p>your code</p>
<?php } ?>
Then you would want to use the isset function to check if the variable is set or not to determine if you want to show the code or not.