Log in

View Full Version : Resolved Help with URL variable conditional statement



Spinethetic
06-03-2009, 06:42 PM
Nature of my goal:
I'am building an affiliate program that pays commissions to affiliates PayPal account.

Problem:
If an affiliate url is like index.php?refer=paypal@mail.com
and I use PHP code on the "Continue page" on an HTML link -


<a href="offerpage.php<?php $ref = $_GET['refer'];echo "?refer=$ref"; ?>">Continue to offer</a>


This works decent, but what if the URL does not have a "refer" variable?
ie: mysite.com/index.php

How can I set it up so that it checks whether or not a value for "refer" exists, and if not than make the link like so-
mysite.com/offerpage.php?refer=mypaypal@mail.com

I hope this is not too confusing :(

Best Regards
~Ross :)

forum_amnesiac
06-04-2009, 07:31 AM
Try this


<a href="offerpage.php<?php $ref = $_GET['refer']; if ($ref==""){ echo "?refer=mypaypal@mail.com";}else{ echo "?refer=$ref"; ?>">Continue to offer</a>

Spinethetic
06-05-2009, 04:27 PM
Thank you, this line seems to be working for me :)