Page 1 of 1

Help With PHP Payment Credits Function - Decreasing Variable

Posted: Tue Aug 23, 2005 5:05 pm
by rabsy
Hope someone can help me out here !!

I have the script below. The problem with the script is that I need it to decrease $a11 by 1 each time the script is executed successfully - (this works fine) UNTIL..... when $a11=1. The script then incorrectly directs the user to a payment page (A link from access_denied6.ihtml) where they are prompted to pay for more credits - but technically they still have one left, if you know what i mean. Hence they should only be sent there when $a11=0.

I need the script below to run as is but reducing $a11 to the min value of zero then when the script is ran, then (AND ONLY THEN) the user is directed to a payment page (access_denied6.ihtml) to pay for more credits which will increase $a11 once more....

I know I need some conditional coding like another if statement, but I can't see where and it is driving me mad !!

Thanks for any help.


Code: Select all

<?
include_once "accesscontrol.php";

$q1 = "select * from job_employer_info where ename = \"$_GET[ename]\" ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);

if(!empty($a1[plan]))
{
$a11 = $a1[JS_number];

if(isset($ename))
 {
$q2 = "select * from job_employer_info where ename = \"$ename\" ";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
    
$a11 = $a11 - 1;
$q4 = "update job_employer_info set JS_number = \"$a11\" where ename = \"$ename\" ";
$r4 = mysql_query($q4) or die(mysql_error());
 }

if ($a11 <= 0)
 {
$a11 = 0;
$q4 = "update job_employer_info set JS_number = \"$a11\" where ename = \"$ename\" ";
$r4 = mysql_query($q4) or die(mysql_error());
include "access_denied6.ihtml";
 }
else
 {
$q = "select * from job_seeker_info where uname = \"$uname\"";
$r = mysql_query($q) or die(mysql_error());
$a = mysql_fetch_array($r);

$q5 = "select * from job_resume where uname = \"$uname\" ";
$r5 = mysql_query($q5) or die(mysql_error());
$a5 = mysql_fetch_array($r5);

include "cvheader.php";
include "cvpreview.ihtml";
include "../footer.php";
 }
}
?>
Cheers

Posted: Tue Aug 23, 2005 5:47 pm
by timvw
You include denied6 if they have 0 or less credits...
You should only do that if they have less than 0 credits...