Jump to content
MakeWebGames

Referals??


newttster

Recommended Posts

I've looked and as far as I have seen ... no one has solved this yet. Is there anyone that has figured out how to get the referals to work? This is the code that I have for all the referal stuff.

register.php info

$_POST['ref'] = (isset($_POST['ref']) && is_numeric($_POST['ref'])) ? abs(intval($_POST['ref'])) : '';
       $IP = $db->escape($_SERVER['REMOTE_ADDR']);
       if ($_POST['ref'] > 0)
       {
           $q = $db->query("SELECT `lastip` FROM `users` WHERE `userid` = {$_POST['ref']}");
           if ($db->num_rows($q) == 0)
           {
               echo "Referrer does not exist.<br />
			> <a href='register.php'>Back</a>";
               exit;
           }
           $rem_IP = $db->fetch_row($q);
           if ($rem_IP == $_SERVER['REMOTE_ADDR'])
           {
               echo "No creating referral multies.<br />
			> <a href='register.php'>Back</a>";
               exit;
           }
       }

 

if ($_POST['ref'])
	{
           $db->query("UPDATE `users` SET `crystals` = `crystals` + 200 WHERE `userid` = {$_POST['ref']}");
           event_add($_POST['ref'], "For refering $username to the game, you have earned 200 valuable crystals!", $c);
		$e_rip = $db->escape($rem_IP);
           $db->query("INSERT INTO `referals` VALUES(NULL, {$_POST['ref']}, $i, unix_timestamp(), '{$e_rip}', '$IP')");
       }

 

<input type=hidden name=ref value='
		<?php
			$_GET['REF'] = abs((int) $_GET['REF']);
			if($_GET['REF']) { print $_GET['REF']; }
		?>
		' />

 

And yes ... on the explore.php file it is set up as

http://www.XXXXX/register.php?REF=#
Edited by newttster
Link to comment
Share on other sites

I believe its case sensitive. In one query you have ref and in another you have REF try making them the same but I am not 100% certain

You're correct.

@OP

Change:

$_POST['ref'] = (isset($_POST['ref']) && is_numeric($_POST['ref'])) ? abs(intval($_POST['ref'])) : '';

To

$_POST['ref'] = (isset($_POST['REF']) && is_numeric($_POST['REF'])) ? abs(intval($_POST['REF'])) : '';
Link to comment
Share on other sites

You're correct.

@OP

Change:

$_POST['ref'] = (isset($_POST['ref']) && is_numeric($_POST['ref'])) ? abs(intval($_POST['ref'])) : '';

To

$_POST['ref'] = (isset($_POST['REF']) && is_numeric($_POST['REF'])) ? abs(intval($_POST['REF'])) : '';

The form is lowercase only the the GET is upper-case in line with what the referral URL is.

Link to comment
Share on other sites

I'll be honest ... I've tried changing them all to REF ... changing them to ref ... a mix of both and nothing has worked. This is one thing that has been driving me nuts about the register.php file. The one thing that I don't understand is how the $_POST['ref'] is supposed to be getting the information from the $_GET['REF'].

Link to comment
Share on other sites

Gotcha. I just saw that and it makes sense. Was so caught up in the REF / ref that I didn't pay attention to the name. *facepalms*

No ... nothing is inserted into the db, there is no event stating that so and so signed up with their referal.Nothing is awarded to the referrer. Nothing. The rest of the register.php file works correctly. Even the promo code works fine.

Edited by newttster
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...