Seker Posted August 21, 2012 Posted August 21, 2012 Okay, when I re-worked my register page, I must have mangled something or misplaced something. As of right now, referals are not working. It's not inserting anything. It's not giving any errors. Just not working. Does anyone see anything really obvious I missed? (Note: Not looking for comments on the validation or the quality of code. Was my first attempt. Just looking for a fix to the referals.) <?php session_start(); require_once(dirname(_FILE_) . "/mysql.php"); require_once(dirname(_FILE_) . "/global_func.php"); ?> <!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> <title>District Wars</title> <body style="background-image: url(/jimages/ui-bg_glow-ball_25_0d230b_600x600.png);background-size:1200px;background-position:center;width:810px;background-repeat:repeat;"> <link rel="stylesheet" href="css/game.css" type="text/css" /> <link rel="shortcut icon" href="images/dwicon.ico"> <style type="text/css"> #divIMG { position: relative ; width:810px; height:781px; margin-left: auto ; margin-right: auto ; background: url('/pics/registerimage.jpg') no-repeat; } #divLOGIN { position:absolute; width:110px; height:20px; top:184px; left:355px; } #divNAME { position:absolute; width:200px; height:20px; top:294px; left:431px; } #divPASS { position:absolute; width:200px; height:20px; top:323px; left:431px; } #divCONFPASS { position:absolute; width:200px; height:20px; top:352px; left:431px; } #divEMAIL { position:absolute; width:200px; height:20px; top:381px; left:431px; } #divPROMO { position:absolute; width:200px; height:20px; top:409px; left:431px; } #divFACEBOOK { position:absolute; width:450px; height:20px; top:185px; left:505px; } #divTWITTER { position:absolute; width:150px; height:20px; top:185px; left:199px; } #divREGISTER { position:absolute; width:110px; height:20px; top:444px; left:519px; } //#divREFERRAL { // visibility: none; //} </style> </head> <body> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <?php $ip = ($_SERVER['REMOTE_ADDR']); if (file_exists('ipbans/' . $ip)) { echo ' <table width="100%"> <tr> <th>Error! Your IP is BANNED!</th> </tr> </table>'; die(''); } if ($_POST['username']) { if (!$_POST['promo']) { $startm = 10000; $startc = 500; } else { if (($_POST['promo'] = 'LAUNCH') || ($_POST['promo'] = 'launch')) { $startm = 15000; $startc = 1200; } else if (($_POST['promo'] = 'FACEBOOK') || ($_POST['promo'] = 'facebook') || ($_POST['promo'] = 'Facebook')) { $startm = 20000; $startc = 1000; } else { $sm = 10000; $startc = 500; } } $username = $_POST['username']; $username = mysql_real_escape_string( htmlentities(stripslashes($username), ENT_QUOTES, 'ISO-8859-1'), $c); $query = sprintf("SELECT `username` FROM `users` WHERE `username`='%s'", $username); $q = mysql_query($query,$c); if (mysql_num_rows($q)) { echo ' <font color="orange">Username already in use. Choose another.</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; } else if ($_POST['password'] != $_POST['cpassword']) { echo' <font color="orange">Error! Your passwords do not match! Go back and try again!</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; } else if (!$_POST['email']) { echo ' <font color="orange">Error! You did not enter an email! Go back and try again!</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; } else if (!$_POST['password']) { echo ' <font color="orange">Error! You did not enter a password! Go back and try again!</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; } else { $_POST['ref'] = abs((int) $_POST['ref']); $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO users (userid, username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip) VALUES('', '{$username}', '{$username}', md5('{$_POST['password']}'), 1, {$startm}, {$startc}, 3, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', " . time() . ", '{$_POST['email']}', -1, '$ip')", $c); $i = mysql_insert_id($c); mysql_query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)", $c); mysql_query("INSERT INTO hunting_USERS VALUES($i,1,10,10,0,0,75)", $c); if ($_POST['ref'] > 0) { $refquery = sprintf("SELECT `userid`,`lastip` FROM `users` WHERE `userid` = %d", $_POST['ref']); $rq = mysql_query($refquery,$c); if (mysql_num_rows($rq) == 0) { mysql_free_result($rq); echo ' <font color="orange">Referrer does not exist.</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; die(''); } $rem_IP = mysql_result($rq, 0, 0); mysql_free_result($rq); if (($rem_IP == $ip) && ($_POST['ref'] != 1)) { echo ' <font color="orange">Error! You share an IP with your referrer!</font><br /> <a href="register.php"><img src="pics/back.png" title="Go Back" alt="Go Back" /></a>'; die(''); } mysql_query("UPDATE `users` SET `crystals` = `crystals` + 100,`refferals`=`refferals`+1 WHERE `userid` = {$_POST['ref']}", $c); event_add($_POST['ref'], "For refering $username to the game, you have gained 100 Tokens!!", $c); $e_rip = mysql_real_escape_string($rem_IP, $c); $e_oip = mysql_real_escape_string($ip, $c); mysql_query("INSERT INTO `referals` VALUES(NULL, {$_POST['ref']}, $i, ' . time() . ', '{$e_rip}', '$e_oip')", $c); } echo ' <table width="100%" align="center"> <tr> <th><font color="orange">You have signed up, enjoy the game.</font></th> </tr> <tr> <td align="center"><a href="login.php"><font color="yellow">Login</font></a><td> </tr> </table>'; } } else { $gref = abs((int) $_GET['REF']); $fref = $gref ? $gref : ''; ?> <div id="divIMG"> <div id="divLOGIN"> <form action="login.php"> <input type="submit" style="width:110px;" value='Log In'> </form> </div> <form action="register.php" method="post"> <div id="divNAME"> <input type="text" name="username" style="width:200px;" value=""> </div> <div id="divPASS"> <input type="text" name="password" style="width:200px;" value=""> </div> <div id="divCONFPASS"> <input type="text" name="cpassword" style="width:200px;" value=""> </div> <div id="divEMAIL"> <input type="text" name="email" style="width:200px;" value=""> </div> <div id="divPROMO"> <input type="text" name="promo" style="width:200px;" value=""> </div> <input type="hidden" name="ref" value='{$fref}'> <div id="divTWITTER"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://districtwars.net" data-text="Sign up to District Wars today!" data-via="DistrictWars" data-related="DistrictWars" data-hashtags="mmorpg">Tweet</a> </div> <div id="divREGISTER"> <input type="submit" style="width:110px;" value="Register"> </div> </form> <div id="divFACEBOOK" class="fb-like" data-href="http://districtwars.net" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div> </div> <?php } ?> </body> </html> Quote
Newbie Posted August 22, 2012 Posted August 22, 2012 try this change mysql_query("INSERT INTO users (userid, username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip) VALUES('', '{$username}', '{$username}', md5('{$_POST['password']}'), 1, {$startm}, {$startc}, 3, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', " . time() . ", '{$_POST['email']}', -1, '$ip')", $c); to mysql_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) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', " . time() . ", '{$_POST['email']}', -1, '$ip')", $c); Quote
Seker Posted August 22, 2012 Author Posted August 22, 2012 I've actually fixed this and since changed my register page again. However, if anyone runs into a similar problem, the issue was using a php variable inside the html form. The solution was changing: <input type="hidden" name="ref" value='{$fref}'> To: <input type="hidden" name="ref" value='<?php $fref ?>'> Can't believe I stared at that for hours and couldn't figure it out. Quote
KyleMassacre Posted September 9, 2012 Posted September 9, 2012 I would like to add a little sumthin sumthin to this hoping it will help as well even though the circumstances are a little different. I had a little problem with referals not working as well and the issue that I had was in explore.php the ref link looked like this: domain.com/register.php?REF=# But in register.php the ref check looked like this if($_GET['ref']) { Execution goes here; } So please try to look and cross reference all your locations with your ref link with your register page cause something so stupid and little like that makes a world of difference. And yes if your using php in straight up html you need to start (<?php) or short tag it <? and stop it ?> Quote
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.