heres is my entire code:
<?
$username = $_SESSION['username'];
$data = mysql_query("SELECT * FROM users WHERE username='$username'")
or die(mysql_error());
$info = mysql_fetch_array($data);
$giftid = $info['gid'];
$ostatus = $info['ostatus'];
$holdreason = $info['holdreason'];
$deadline = $info['deadline'];
$dead = $info['dead'];
$date = date("F j, Y");
$uid = $info['uId'];
$result = mysql_query("select * from users WHERE rid=$uid");
$count=mysql_num_rows($result);
$result2 = mysql_query("select * from users WHERE rid=$uid && ostatus=1");
$count2=mysql_num_rows($result2);
//show gift
$data3 = mysql_query("SELECT * FROM gifts WHERE gId='$giftid'")
or die(mysql_error());
$num = mysql_num_rows($data3);
if ($num == 0) {
$data10 = mysql_query("SELECT * FROM gifts");
$info = mysql_fetch_array($data10);
$giftid = $info['gId'];
$query="UPDATE users SET gid='$giftid' WHERE username='$username'";
mysql_query($query);
echo '<meta http-equiv="refresh" content="0;url=main.php">';
}
$data2 = mysql_query("SELECT * FROM gifts WHERE gId='$giftid'");
$r = mysql_fetch_array($data2);
$gname=$r["gName"];
$gref=$r["gRef"];
$gdescription=$r["gDescription"];
$gimage=$r["gImage"];
if ($date != $deadline && $dead == 0 or $date == $deadline && $count2 == $gref && $ostatus == 1) {
?>
</p>
<div style="margin-left:200px "><font color="#0066FF">You Have Until <? echo "$deadline"; ?> To Complete The Requirements</font></div><Br>
<div id="mygift">
<div class="myname"><? echo "$gname"; ?></div>
<div align="center" style="color:red ">Item Requires <? echo "$gref"; ?> Referrals</div>
<div class="myimage"><img src="<? echo "$gimage" ?>"/></div>
<div class="myname"><? echo "$gdescription"; ?></div>
<div align="right" style="text-decoration:none;"><a href="gifts.php">Change My Gift</a></div>
</div><br>
<div align="center">Your Referral Link <input name="referral" type="text" value="http://www.thefreebielife.com?r=<? echo "$uid"; ?>" size="50">
</div>
<bR>
<?
$ostatus='1';
if($rid == '1') {
THEN code.
}
?>
<div class="border"></div><br>
<div class="myname">My Status</div>
<div align="center"><? if ($ostatus == 1) { ?> <font color="#009900"> You Have Completed An Offer!</font><? } else if ($ostatus == 0) { ?><font color="#000000"> You Have Not Completed An Offer</font><? } else if ($ostatus == 2) { ?><font color="red"> You Have Been Placed On Hold <Br> <strong>Hold Reason: <? echo "$holdreason"; ?></strong></font><? } ?>
<br>
<br>
</div>
<?
$data4 = mysql_query("SELECT * FROM orders WHERE ousername='$username'");
$count4=mysql_num_rows($data4);
?>
<? if ($count2 < $gref) { ?>
<div align="center">You Have <? echo "$count2"; ?> Completed Referrals Out of <? echo "$gref"; ?> Needed</div>
<? } ?>
<? if ($count2 == $gref && $ostatus == 0) { echo "<div align=center><font color=red>You Are So Close. All You Need To Do Is Complete An Offer!</font></div>"; } ?>
<? if ($count2 >= $gref && $ostatus == 1 && $count4 == 0) { echo "<div align=center><font color=#009900>Congrats! You Are Ready To Order Your Free Gift. </font><font color=red><a href=\"order.php\"> Click To Order</a></font><Br>Make Sure Your Information Is Correct Before Ordering. It Cannot Be Changed</div>"; } ?>
<? if ($count2 >= $gref && $ostatus == 1 && $count4 == 1) { echo "<div align=center><a href=\"order.php\"><font color=blue>Click To Check The Status Of Your Order</font></a></div>"; } ?>
<br>
<table width="400" border="0" align="center" class="reftable">
<tr>
<td colspan="2" style="border-bottom:1px dashed orange "><div align="center">Your Referrals </div></td>
</tr>
<tr>
<td width="50%" style="border-right: 1px dashed orange; border-bottom:1px dashed orange"><div align="center">Username</div></td>
<td width="50%" style="border-bottom:1px dashed orange"><div align="center">Offer Status</div></td>
</tr><? if ($count == 0) { ?>
<tr>
<td colspan="2"><div align="center"><font color="#FF0000">You Have No Referrals</font></div></td>
</tr>
<? } ?>
<?
//grab all the content
while($r=mysql_fetch_array($result))
{
$ruser=$r["username"];
$roffer=$r["ostatus"];
?>
<tr>
<td width="50%" style="color:#0099FF "><div align="center"><? echo "$ruser"; ?></div></td>
<td width="50%"><div align="center"><? if ($roffer == 1) { echo "<font color=#009900>Offer Completed</font>"; } else if ($roffer == 0) { echo "<font color=red>Offer Not Completed</font>"; } else if ($roffer == 2) { echo "<font color=red>User Removed</font>"; }?> </div></td>
</tr>
<? } ?>
</table> <p>
<center><img src="images/offer.gif"></center> <p>
<? } else { echo "<div align=center><font color=red><h1>The Dead Line Has Past. <br> Your Account Is No Longer Active</h1></font></div>";
if ($dead == 0) {
$query="UPDATE users SET dead=1 WHERE username='$username'";
mysql_query($query);
}
} ?>
basically this part doesnt work:
<?
$ostatus='1';
if($rid == '1') {
THEN code.
}
?>
basically.. user signs up under a referral id. 1 in this case.
i want it to be so that the script automatically goes into the database and changes their offer status to complete.