Gubbins Posted January 8, 2010 Share Posted January 8, 2010 Can anyone help please? I have a file given to me that provides a Referral link like this:- http://www.gbmafia.com/register.php?ref=Gubbins In the database i have the following field:- Field=referral Type=INT Length/values=11 In the register.php file i put the following:- $reff = $_POST['reff']; mysql_query("UPDATE players SET referral=referral+1 WHERE playername='$reff'"); But this doesn't enter anything into the database. Can anyone see where i have gone wrong please? Thanks Gubbins Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/ Share on other sites More sharing options...
cags Posted January 8, 2010 Share Posted January 8, 2010 Variables in the query_string (at the end of a URL) are in the $_GET array, not the $_POST array. Also the link uses 'ref' whereas the key you attempted to use in the $_POST array is 'reff'. Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991366 Share on other sites More sharing options...
Gubbins Posted January 8, 2010 Author Share Posted January 8, 2010 Variables in the query_string (at the end of a URL) are in the $_GET array, not the $_POST array. Also the link uses 'ref' whereas the key you attempted to use in the $_POST array is 'reff'. arr yes i follow most of what you said but if you don't mind could you show me what you mean so i know how to write it in the register file. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991370 Share on other sites More sharing options...
PHP Monkeh Posted January 8, 2010 Share Posted January 8, 2010 Make sure it's: $reff = $_GET['reff']; Where 'reff' is the name of the variable in the URL (if the link you posted is the case it will be 'ref' rather than 'reff'). Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991373 Share on other sites More sharing options...
RaythMistwalker Posted January 8, 2010 Share Posted January 8, 2010 complete fixed code: $ref = $_GET['ref']; mysql_query("UPDATE players SET referral=referral+1 WHERE playername='$ref'"); Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991374 Share on other sites More sharing options...
Gubbins Posted January 8, 2010 Author Share Posted January 8, 2010 complete fixed code: $ref = $_GET['ref']; mysql_query("UPDATE players SET referral=referral+1 WHERE playername='$ref'"); Worked 1st time, Thank you all very much Gubbins Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991378 Share on other sites More sharing options...
cags Posted January 8, 2010 Share Posted January 8, 2010 One note of caution, the method you are using is rather insecure, I'd recommend reading up on mysql_real_escape_string. Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991379 Share on other sites More sharing options...
Gubbins Posted January 8, 2010 Author Share Posted January 8, 2010 One note of caution, the method you are using is rather insecure, I'd recommend reading up on mysql_real_escape_string. arr ok sounds like i need to then is it an easy fix? Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991380 Share on other sites More sharing options...
cags Posted January 8, 2010 Share Posted January 8, 2010 Depends on your server settings. If magic_quotes_gpc is disabled then all you should need to change is to pass the $_GET variable through the functions. IE... $ref = mysql_real_escape_string($_GET['ref']); Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991386 Share on other sites More sharing options...
Gubbins Posted January 8, 2010 Author Share Posted January 8, 2010 Depends on your server settings. If magic_quotes_gpc is disabled then all you should need to change is to pass the $_GET variable through the functions. IE... $ref = mysql_real_escape_string($_GET['ref']); That worked a treat.. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/187770-referral-programme/#findComment-991390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.