Hey the following code is not working as it should although I cannot see any problems with it.
We have to assume that the user has visited the webpage using a link similar to the following
www.somewhere.com/index.php?ref=manixmitch
Please can you take a look and help me out? Thanks in advance.
<?
//Start Session
session_start();
//Set the cookie so that people can't just refresh
setcookie( "visit", "Y", time()+2592000 ) or die ("line 65");
//Connect to database
include("connectdb.inc.php");
//Check if user has been before
if ($visit==Y) {} else {
//Checks $ref variable
if ($ref==NULL) {}
else
{
//Select all information for normal members
$getnormrefs=mysql_query("select refs, points from outwarinfo where username=\"$ref\" ") or die ("Could not get ref, points info line 27");
while ($refnormrow=mysql_fetch_array($getnormrefs) )
{
//Set points and referals as varibles
$normrefs=$refnormrow[refs];
$pointref=$refnormrow[points];
}
//Add all the new points and referals to variables
$pointrefnew=$pointref+10;
$newnormrefs=$normrefs++;
//Update users referal account
mysql_query("update outwarinfo set refs=\"$newnormrefs\" where username=\"$ref\" ") or die ("line 47");
//If the user has 50 referals give them a bonus 10 points
if ($newnormrefs==50)
{
//If this is true set make the $pointrefnew variable the users points & give the user 1 more referal to stop them getting the bonus more than once
mysql_query("update outwarinfo set points=\"$pointrefnew\" where user=\"$ref\" ") or die ("line 79");
mysql_query("update outwarinfo set refs=\"51\" where user=\"$ref\" ") or die ("line 80");
}
}
if ($user==NULL) {}
{
//Get all admin information
$getrefs=mysql_query("select refs, admin from admininfo where username=\"$user\" ") or die ("line 51");
while ($refrow=mysql_fetch_array($getrefs) ) { $referals=$refrow[refs]; }
//Make a new referals variable
$newrefs=$referals++;
//Change the users referals
mysql_query("update admininfo set refs=\"$newrefs\" where username=\"$user\" ") or die ("line 61");
//If the user has 200 referals make them an administrator
if ($newrefs==200)
{
//Update the admin table saying that the user is now a fully fledge administrator
mysql_query("update admininfo set admin=\"Y\" where username=\"$user\" ") or die ("line 92");
}
}
}
//Set date variables and chack if this has already been run today.
$date = date ("Ymd");
$query = "Select * from date where date = $date";
$Result = mysql_query($query);
/* If date is found then script has already been run and it does nothing, if it hasn't found the date then
it inserts it and executes the other functions */
if (mysql_fetch_array ($Result) ) {}
else
{
//Write date to file and perform other functions
mysql_query("insert into date (date) values ($date)");
mysql_query("update outwarinfo set advert4=\"N\" ");
mysql_query("update outwarinfo set advert5=\"N\" ");
mysql_query("update outwarinfo set advert7=\"0\" ");
}
?>