Hmm...well, I have added the function to the payout page, but it always shows 0.00, even though I set the function to 120 seconds for testing.
Here is the updated payout.php file:
<? session_start();
if (!$_SESSION['username']) {
{
header("Location: index.php");
exit;
}
include "../aff.php";
mysql_connect($host, $usr, $pwd) or die ("Database CONNECT Error (line 18)");
$query = mysql_db_query($database, "select * from affiliates where email = '".$_SESSION['username']."'") or die ("Cannot select");
$result = mysql_query($query);
$query2 = "SELECT SUM(payment) FROM sales";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2);
$total2=sprintf("%01.2f",$row2[0]);
$query3 = "SELECT SUM(payment) FROM sales WHERE now() > wait";
$result3 = mysql_query($query3);
$row3 = mysql_fetch_array($result3);
$available = sprintf("%01.2f",$row3[0]);
echo "You have currently earned \$$total2.";
if ($row2 < 20) {
$need = 20-$total2;
echo "<br>You will need to earn \$$need to be eligible for a payout. Keep up the good work!";
} else {
echo "<br>Congratulations! You have earned enough for a payout!<br>You have earned a total of \$$total2. \$$available is available for payout right now.
<form name='payout' action='payoutrequest.php' method='POST'>
<input type='hidden' name='aff' value='".$_SESSION['username']."'>
Amount to be paid out: <input type='text' name='payout' value='$available'>
<br>Would you like your earnings applied to your hosting fees (if applicable) or paid in cash via Paypal? <input type='radio' name='cashorfees' value='Hosting'> Hosting Fees
<input type='radio' name='cashorfees' value='Cash'> Cash<br>";
echo "<input type='hidden' name='email' value='$result'>
<input type='submit' name='submit' value='Send Payout Request >>'>
</form>";
}
?>
Did I add the code in the right format/spot? This is what the test orders in the db look like:
INSERT INTO `sales` VALUES ('test', '2003-10-12', '22:50:00', '', '9.5', 'rLite', 1066017125);
INSERT INTO `sales` VALUES ('test', '2003-10-12', '22:50:00', '', '9.5', 'rLite', 1066017127);
INSERT INTO `sales` VALUES ('test', '2003-10-12', '22:50:00', '', '9.5', 'rLite', 1066017129);
Should the numbers in the last column be so long? I currently have the column set at bigint; should I change it?
Thanks! 🙂