Sethenor2 Posted June 26, 2011 Share Posted June 26, 2011 Hi for some reason my referrals don't seem to work i am currently using McCodes 2.0.3 I dont enter the database Can i get some help please Cheers Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 26, 2011 Share Posted June 26, 2011 A little more info may help... any errors in your query? Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 26, 2011 Author Share Posted June 26, 2011 No errors at all just don't update the db and user Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 26, 2011 Share Posted June 26, 2011 No errors at all just don't update the db and user Well try running the query via phpmyadmin. If the query is fine check for anything that could be preventing it from running e.g. exit; randomly placed. I can't really do much with "it's not working". Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 26, 2011 Author Share Posted June 26, 2011 This is my register and database table When someone registers and put i.e 1 in promo code the player registers but it does not add it to the database Any help would be appreciated CREATE TABLE `referals` ( `refID` int(11) NOT NULL auto_increment, `refREFER` int(11) NOT NULL default '0', `refREFED` int(11) NOT NULL default '0', `refTIME` int(11) NOT NULL default '0', `refREFERIP` varchar(15) NOT NULL default '127.0.0.1', `refREFEDIP` varchar(15) NOT NULL default '127.0.0.1', PRIMARY KEY (`refID`) ) ENGINE=MyISAM ; <?php include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } //thx to http://www.phpit.net/code/valid-email/ for valid_email function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } session_start(); print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Fallen City- Login</title> <link href="front.css" media="screen, projection" rel="stylesheet" type="text/css"> </head> <body> <center> <table width="850" border="0" align="center" cellspacing="0"> <tr bgcolor="#000000"> <td width="850" height="400" background="images/fc.png" valign="top"><div id="container"> <div id="topnav" class="topnav" >Are you a member? <a href="login" class="register"><span>Register</span></a> </div> <fieldset id="register_menu"> <form action=register.php method=post name=register> <label for="username">Username</label> <input type=text name=username onkeyup='CheckUsername(this.value);'><div id='usernameresult'></div> </p> <p> <label for="password">Password</label> <input type=password id='pw1' name=password onkeyup='CheckPasswords(this.value);PasswordMatch();'><div id='passwordresult'></div> </p> <p> <label for="cpassword">Confirm Password</label> <input type=password name=cpassword id='pw2' onkeyup='PasswordMatch();'><div id='cpasswordresult'></div> </p> <p> <label for="email">Email</label> <input type=text name=email onkeyup='CheckEmail(this.value);'><div id='emailresult'></div> </p> <p> <label for="gender">Gender</label><br /> <select name='gender' type='dropdown'> <option value='Male'>Male <option value='Female'>Female</select> </p> <p> <center><input id="register_submit" value="Register" tabindex="6" type="submit"></center> </p></td> </form> </fieldset> </div> <script src="javascripts/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".register").click(function(e) { e.preventDefault(); $("fieldset#register_menu").toggle(); $(".register").toggleClass("menu-open"); }); $("fieldset#register_menu").mouseup(function() { return false }); $(document).mouseup(function(e) { if($(e.target).parent("a.register").length==0) { $(".register").removeClass("menu-open"); $("fieldset#register_menu").hide(); } }); }); </script> <script src="javascripts/jquery.tipsy.js" type="text/javascript"></script> <script type='text/javascript'> $(function() { $('#forgot_username_link').tipsy({gravity: 'w'}); }); </script></td></tr> <tr class="info"> <td background="images/bottom.png" align="center" height="98" valign="middle"> <!-- Begin Main Content --> EOF; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if(file_exists('ipbans/'.$IP)) { die("Sorry Your IP has been Banned."); } if($_POST['username']) { if($set['regcap_on']) { if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha']) { unset($_SESSION['captcha']); die("Captcha Test Failed."); } unset($_SESSION['captcha']); } if(!valid_email($_POST['email'])) { die("You entered and incorrect E-mail address."); } if(strlen($_POST['username']) < 4) { die("Sorry the Username you choose is to short.>"); } $sm=100; if($_POST['promo'] == "Your Promo Code Here") { $sm+=100; } $username=$_POST['username']; $username=str_replace(array("<", ">"), array("<", ">"), $username); $q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'"); $q2=$db->query("SELECT * FROM users WHERE email='{$_POST['email']}'"); if($db->num_rows($q)) { print "The Username you choose is in use."; } else if($db->num_rows($q2)) { print "The E-mail you choose is in use."; } else if($_POST['password'] != $_POST['cpassword']) { print "Your passwords do not match."; } else { $_POST['ref'] = abs((int) $_POST['ref']); $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $q=$db->query("SELECT * FROM users WHERE lastip='$IP' AND userid={$_POST['ref']}"); if($db->num_rows($q)) { die("No creating referral multies. Bad dog.<br /> ><a href='register.php'>Back</a>"); } if($_POST['ref']) { $q=$db->query("SELECT * FROM users WHERE userid={$_POST['ref']}"); $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$IP', '$IP')"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)"); if($_POST['ref']) { require "globalfunctions.php"; $db->query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}"); event_add($_POST['ref'],"For refering $username to the game, you have earnt 2 valuable crystals!",$c); $db->query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$IP')"); } print "Thank you for joining, Have fun!<br> <form action=authenticate.php method=post name=login> <p> <label for='username'>Username</label> <input type=text name=username> <label for='password'>Password</label> <input type=password name=password> <input id='signin_submit' value='Sign in' tabindex='6' type='submit'> </p> </form>"; } } else { if($set['regcap_on']) { $chars="123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?\\/%^"; $len=strlen($chars); $_SESSION['captcha']=""; for($i=0;$i<6;$i++) $_SESSION['captcha'].=$chars[rand(0, $len - 1)]; } print "<form action=authenticate.php method=post name=login> <p> <label for='username'>Username</label> <input type=text name=username> <label for='password'>Password</label> <input type=password name=password> <input id='signin_submit' value='Sign in' tabindex='6' type='submit'> </p> </form>"; } print <<<OUT </td> <td class="rgrad"></td> </tr> <tr> <td colspan="3"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td class="dgradl"> </td> <td class="dgrad"> </td> <td class="dgradr"> </td> </tr> </table> </td> </tr> </table> </center> </body> </html> OUT; ?> Quote Link to comment Share on other sites More sharing options...
Uridium Posted June 26, 2011 Share Posted June 26, 2011 Only thing i can see is your use of require "globalfunctions.php"; instead of the usual require "global_func.php"; Im not saying this is the error cos you may have renamed the global_func.php to match the globalfunctions.php Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 26, 2011 Share Posted June 26, 2011 This is my register and database table When someone registers and put i.e 1 in promo code the player registers but it does not add it to the database Promo is $_POST['promo'], and is set in the file. If you get it right you gain a little extra upon registering. It's not the ref system. Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 26, 2011 Author Share Posted June 26, 2011 Only thing i can see is your use of require "globalfunctions.php"; instead of the usual require "global_func.php"; Im not saying this is the error cos you may have renamed the global_func.php to match the globalfunctions.php I just renamed it :P Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 26, 2011 Author Share Posted June 26, 2011 Promo is $_POST['promo'], and is set in the file. If you get it right you gain a little extra upon registering. It's not the ref system. Ok yeah but the referral is not working i dont have a clue why Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 27, 2011 Author Share Posted June 27, 2011 Anyone got any idea's Quote Link to comment Share on other sites More sharing options...
Uridium Posted June 27, 2011 Share Posted June 27, 2011 are you wanting promo or Referal ? Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 27, 2011 Author Share Posted June 27, 2011 are you wanting promo or Referal ? Referral it dont work at all Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 27, 2011 Share Posted June 27, 2011 Referral it dont work at all You said you where putting the Id of the user into the "promo" section? Are you using the link from explore.php? Every user has an referral link. Just to check, is the rest of the register page working? Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted June 27, 2011 Author Share Posted June 27, 2011 You said you where putting the Id of the user into the "promo" section? Are you using the link from explore.php? Every user has an referral link. Just to check, is the rest of the register page working? I have tried the referral link and still nothing and yeah register works fine Quote Link to comment Share on other sites More sharing options...
Dominion Posted June 27, 2011 Share Posted June 27, 2011 echo "ref" out, and see if it's what you expect it to be? Quote Link to comment Share on other sites More sharing options...
Smokey Posted August 24, 2011 Share Posted August 24, 2011 I have a similar problem, but with mine, sometimes it works, sometimes it doesnt. I dont understand that but it really only works about a third of the time, and also using v 2.0.3, but I plan to get a new referral system when I find a decent one so I'm not to worried about it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.